[squeak-dev] Strange Unix file behavior?

Tony Garnock-Jones tonyg at lshift.net
Thu Aug 7 12:29:48 UTC 2008


David T. Lewis wrote:
> Strictly speaking, opening a directory as a file stream is not wrong.

Interesting. I was under the impression that that changed, quite some 
time ago now. I recall using cat on directories in Minix 1.5, and 
getting halfway-useful (if file-system specific) results, but modern 
Linux and OS X machines don't seem to let you read anything out of 
directories without using the special directory-traversal functions.

> Similarly, in Squeak it would make sense to be able to open a directory
> file as a file stream, and then be able to read its contents.

What would you expect read(2) on a directory to return? Is it standardised?

What would reading from a Smalltalk file stream on a directory return? 
Bytes? Strings? Other file streams? Some other kind of object?

> My personal opinion is that allowing a directory file to be opened
> as a file stream is good, and failing to allow the contents of the
> stream to be read is bad.

I'd be happier treating directories as yet another kind of specialised 
collection, rather than a stream. They can be encoded into a stream, 
sure, but the details of the encoding will vary platform by platform, 
and file-system-type by file-system-type.

Tony




More information about the Squeak-dev mailing list