How to get the file reader class for a file name
Last updated at 8:24 pm UTC on 11 June 2018
Use
FileServices itemsForFile: fileName
Example 1:
FileServices itemsForFile: 'myPresentation.morph'
Result:
an OrderedCollection(FileModifyingSimpleServiceEntry: (ArchiveViewer — addFileToNewZip:)
SimpleServiceEntry: (FileStream — edit:)
FileModifyingSimpleServiceEntry: (GZipWriteStream — compressFile:)
SimpleServiceEntry: (Morph --- fromFileName:)
SimpleServiceEntry: (ProjectViewMorph — openFromDirectoryAndFileName:))
Example 1:
FileServices itemsForFile: 'myPicture.jpg'
Result:
an OrderedCollection(FileModifyingSimpleServiceEntry: (ArchiveViewer — addFileToNewZip:) SimpleServiceEntry: (FileStream — edit:)
SimpleServiceEntry: (Form — importImage:) SimpleServiceEntry: (Form — importImageAndShowImports:) SimpleServiceEntry:
(Form — openImageInWindow:) SimpleServiceEntry: (Form — openAsBackground:))
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