About the Registering File list

ducasse ducasse at iam.unibe.ch
Thu Jan 31 19:23:17 UTC 2002


on 31/01/02 7:05 PM, Ned Konz at ned at bike-nomad.com wrote:

> On Thursday 31 January 2002 03:31 am, Stephane Ducasse wrote:
> 
>> So the file list only knows the classes and not the services which have
>> been register.
> 
> I'm in favor of letting the reader classes decide:
> 
> * whether they're going to handle a specific file or not (not just by suffix!)
> 
> * what services they want to provide for a specific file
> 
> I'd suggest registering classes using file suffixes (as an optimization for
> readers that care about suffixes), and then before popping up a menu, passing
> the name of the selected file(s) to the registered reader classes.
> 
> If you include '*' as a file suffix that can be registered, it would allow
> readers to decide on a file-by-file basis.
> 
> This is important for some files that may not have predictable file suffixes
> (I'm thinking here of ZIP files, which may have suffixes like .zip .ZIP .exe
> .EXE .pr .PR, etc...) and would benefit from being looked at (for magic
> numbers, etc.).

I was thinking about the same in fact. So I will try to use that.


> That is, I'd have something like this (probably pseudo-code):
> 
> ArchiveViewer class >>initialize
> FileList registerReader: self forSuffixes: #( * ).
> 
> ArchiveViewer class>>servicesForFile: aFileName
> services := OrderedCollection new.
> (aFileName isZipFile) ifTrue: [
> services add: (SimpleServiceEntry
> provider: self
> label: 'view zip'
> selector: #viewZip:)
> ].
> services add: (SimpleServiceEntry
> provider: self
> label: 'add to zip'
> selector: #addFileToNewZip:) .
> ^services
> 
> and before popping up a menu, the FileList would call all the reader classes
> that had expressed an interest in the given file suffix (plus all those who'd
> registered '*'). The results would be added to the menu.




More information about the Squeak-dev mailing list