[squeak-dev] filename extensions for Form reading
tim at rowledge.org
Sat Dec 23 00:12:04 UTC 2017
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 Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Java: the best argument for Smalltalk since C++
More information about the Squeak-dev