Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to get the file reader class for a file name
Last updated at 8:37 am UTC on 30 March 2017
Use
 FileServices itemsForFile: fileName
Example:
 FileServices itemsForFile: 'myPresentation.morph'

Result:
  an OrderedCollection(FileModifyingSimpleServiceEntry: (ArchiveViewer — addFileToNewZip:) 
     SimpleServiceEntry: (FileStream — edit:) 
     FileModifyingSimpleServiceEntry: (GZipWriteStream — compressFile:) 
     SimpleServiceEntry: (Morph — fromFileName:) 
     SimpleServiceEntry: (ProjectViewMorph — openFromDirectoryAndFileName:))


Implementation:

 FileServices class

 itemsForFile: fullName
	"Answer a list of services appropriate for a file of the given full name"

	| services suffix |
	suffix := self suffixOf: fullName.
	services := OrderedCollection new.
	self registeredFileReaderClasses do: [:reader |
		reader ifNotNil: [services addAll: (reader fileReaderServicesForFile: fullName suffix: suffix)]].
	^ services