[BUG] String asURL fails

Lex Spoon lex at cc.gatech.edu
Thu Mar 7 16:40:05 UTC 2002


"Stephen Pair" <spair at advantive.com> wrote:
> > I can't test on a Mac, but this changeset should at least be 
> > very close.  You'll have to change the #asUrl to this new 
> > selector, but hopefully that's okay.
> 
> I think this needs to go a step further.  The construct:
> 
> 	FileUrl fromFileName: 'Macintosh HD:Fun with 3.2:Squeak.15.gif'
> 
> should work no matter what platform you are on, or alternatively you
> should be able to to be explicit about the platform (with the previous
> example parsing based on the current platform)...for example:
> 
> 	FileUrl fromMacFileName: 'Macintosh HD:Fun with
> 3.2:Squeak.15.gif'


How about sticking it in the FileDirectory classes?  Then you can
customize an application by handing it the relevant FileDirectory
subclass.  Such a beast will also come along with other
platform-specific name management tools like splitName:to:.

	FileDirectory urlForFilename: blah
	FileDirectory urlForDirectoryName: blah

	MacFileDirectory urlForFilename: blah


That is, vary the class, instead of the selector, to get different
behaviors.  In fact, if you implement the methods in class
FileDirectory, you can probably get away with just one method for
filenames and one method for directory names -- the methods will be
implicitly customized by the particular subclass that was used!



> 
> Unfortunately, there are many methods that assume you want the local
> file name convention and directly use "FileDirectory pathNameDelimiter"
> or FileDirectory activeDirectoryClass. 


Well, yes, that's true.  I happen to think this is normal and correct,
but I doubt we'll agree.  I never have reason to process a windows or a
MacOS or a RiscOS filename, and it's hard for me to imagine cases where
I'd want to.  Filenames are implicitly a local thing, IMHO.


> Also, shouldn't
> "MacFileDirectory on: 'Macintosh HD:Fun with 3.2:Squeak.15.gif'" give me
> an instance of a MacFileDirectory?  It currently doesn't work unless you
> happen to be running on the mac plaform.

Interesting.  Whether this *should* work I don't know, because you can
think of a FileDirectory object as *being* the directory, which is
impossible except on a Macintosh.  Still, it would be nice to have
*some* way to manage filenames from a foreign OS....


-Lex



More information about the Squeak-dev mailing list