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

David T. Lewis lewis at mail.msen.com
Mon Aug 5 22:33:05 UTC 2002


On Mon, Aug 05, 2002 at 02:41:49PM -0800, Alan Kay wrote:
> What about using backslash "\"?
 
Backslash is heavily laden with meaning in other contexts, including
C language and many common Unix utilities.

> At 10:30 PM +0200 8/5/02, Andreas Raab wrote:
> >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'.
> >
> >To get the file 'foo/bar/baz/mumble.file' you would say:
> >
> >file := FileDirectory default, 'foo', 'bar', 'baz', 'mumble.file'.

This gets the job done, and avoids the platform-specific part of the
problem, but it seems to be confusing the concept of a file name path
with the concept of a container for directory entries.

If you were to invent a FileDirectoryPath, you would want it to handle
all of the path navigation issues in a platform-independent way, and you
would want it to know how to do the right thing in response to an #open
message (open an appropriate kind of FileDirectory or FileStream).

We already have a FileUrl, which aspires to be a platform-independent
representation of a local filesystem path to a file or directory (or
other "filesystem object" on some platforms). Perhaps it would be
cleaner to add the missing behaviors there?

> >BTW, I had considered using '/' but it looks kinda ugly to write
> >	FileDirectory default / 'foo' / 'bar' / 'baz'.
> >comma is already a concatenation operator and makes the cross-platform
> >aspect a little clearer.

Yes.

- Dave

p.s. This suggests digging up the ANSI spec for Smalltalk, which might
possible have some useful suggestions from folks who have thought this
through a bit. Let's see now, I know I saved a copy of that someplace...




More information about the Squeak-dev mailing list