[squeak-dev] Strange Unix file behavior?

David T. Lewis lewis at mail.msen.com
Thu Aug 7 12:02:38 UTC 2008


On Thu, Aug 07, 2008 at 12:17:50AM -0700, Andreas Raab wrote:
> I just noticed the following strange behavior on Unix:
> 
> FileDirectory default fileExists: 'foo'.
>   => false "as expected"
> 
> FileDirectory default fileExists: ''.
>   => false "as expected"
> 
> FileDirectory default fileExists: '.'.
>   => false "as expected"
> 
> FileDirectory default fileExists: '..'.
>   => false "as expected"
> 
> FileDirectory default readOnlyFileNamed: 'foo'.
>   => FileDoesNotExistException "as expected"
> 
> FileDirectory default readOnlyFileNamed: ''.
>   => MultiByteFileStream: '/home/qwaq/server/bin/forums/' "Huh?"
> 
> FileDirectory default readOnlyFileNamed: '.'.
>   => MultiByteFileStream: '/home/qwaq/server/bin/forums/.' "WTF?"
> 
> FileDirectory default readOnlyFileNamed: '..'.
>   => MultiByteFileStream: '/home/qwaq/server/bin/forums/..' "????"
> 
> Is this expected behavior? If not, any ideas how to fix it?

Strictly speaking, opening a directory as a file stream is not wrong.
Whether it's expected or desirable is a matter of opinion. For a unix
filesystem, a directory is a file, and you can for example open a directory
in a text editor, or view its contents with /bin/cat or /usr/bin/od.
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.

Certainly it is inconsistent to report that the file directory
does not exist, but then allow you to open it as a file stream.
No, it's not expected behavior (at least not to me).

Also, this seems inconsistent:

(FileDirectory default readOnlyFileNamed: '.') size
 => 24576 "as expected"

(FileDirectory default readOnlyFileNamed: '.') next
  => nil "??? expected to read something"

(FileDirectory default readOnlyFileNamed: '.') contentsOfEntireFile
  => '' "??? expected a string"

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.

Dave




More information about the Squeak-dev mailing list