filename extensions for Form reading

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

filename extensions for Form reading

timrowledge
I’m looking at ImageMorph>>#readFromFile and find myself a bit puzzled. The initial code is simple enough but essentially lets a user enter any sort of filename whatsoever and then relies upon the Form>>fromFileNamed: method handling anything odd - which will be lots of fun if the file doesn’t exist (because the not-there-readonlyfile error is not handled at all) or is not actually an image file (because notifier). Sigh.

I was intending to improve this by using a nice new FileChooserDialog which would show only image files by filtering on the typical file extensions, or at least the ones we can handle (not much point with any others). The problem then becomes how to find those extensions; it might look like ImageReadWriter class>>allTypicalFileExtensions would do it but if we look for usages things get oh so much muddier.

In Form class>>#fileReaderServicesForFile:suffix: for example, we use #allTypicalFileExtensions and add ‘form’. And rather weirdly, ‘*’ too, which must surely be a mistake?
FileList2 class>>#endingSpecs does a quite odd looking sequence of making an array of arrays where the contents of an array are immediately replaced by the results of ImageReadWriter allTypicalFileExtensions, making me wonder “why?”
Imports>>#importImageDirectory: collects file extensions with "ImageReadWriter allTypicalFileExtensions add: ‘form’ “

So unless I've missed something, it would be more useful to implement Form class> allTypicalFileExtensions as
^ImageReadWriter allTypicalFileExtensions add: ‘form’.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Java:  the best argument for Smalltalk since C++



Reply | Threaded
Open this post in threaded view
|

Re: filename extensions for Form reading

Bob Arning-2

Originally this provided filtering for the novice user to open particular kinds of files. In 2003 it was updated to use the services registry rather than the hard-coded descriptions and methods. At that time it was also modified to use the the suffixes for graphics files generated by ImageReadWriter subclasses rather than the static list in the method. Which basically changed this

'bmp' 'form' 'gif' 'jpeg' 'jpg' 'pbm' 'pcx' 'png' 'ppm' 'xbm' 'xpm'

into this

'bmp' 'gif' 'jpeg' 'jpg' 'pam' 'pbm' 'pcx' 'png' 'pnm' 'ppm' 'xbm'


On 12/22/17 7:12 PM, tim Rowledge wrote:
FileList2 class>>#endingSpecs does a quite odd looking sequence of making an array of arrays where the contents of an array are immediately replaced by the results of ImageReadWriter allTypicalFileExtensions, making me wonder “why?”