Cross-platform path specification (was RE: Access directory relatively)

Tim Rowledge tim at sumeru.stanford.edu
Mon Aug 5 21:28:03 UTC 2002


"Andreas Raab" <Andreas.Raab at gmx.de> is claimed by the authorities to have written:

> That actually reminds me of something - I had to use relative paths
> lately in cross-platform ways and the current way of [not] dealing with
> it really sucks. So here's a proposal for introducing FileDirectory>>,
> for referencing either files or directories. E.g., in order to get a
> directory 'foo/bar/baz' you'd write:
> 
> dir := FileDirectory default, 'foo', 'bar', 'baz'.
That, I quite like. Simple, avoids long messagenames, reasonably
intuitable. Good.

> 
> To get the file 'foo/bar/baz/mumble.file' you would say:
> 
> file := FileDirectory default, 'foo', 'bar', 'baz', 'mumble.file'.
That's a little harder; how would one discriminate that it isn't another
level of directory?

One _could_ decide that the resut is a FileName object rather than a
file or FileDirectory. That would provide a useful abstraction anyway.
Then maybe we could get away from FileStream handling file name stuff at
last.
> 
> The returned file would be closed so you'd have to open it through:
> 
> file open: #readOnly.
> file open: #readWrite.
This would of course work perfectly well with a FileName object.

There are some uglinesses lying in wait for anything in this area. For
example, given a FileName, one then has to do other stuff to be able to
handle #directoryContents (what if the file name represents a file not
a directory?) and #open (what if the file name represents a directory
nota file?).

Nonetheless I think the paradigm for the naming is pretty good.

tim

-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Java:  the best argument for Smalltalk since C++




More information about the Squeak-dev mailing list