[BUG] Problem creating FileStream on Macs?

ohshima at is.titech.ac.jp ohshima at is.titech.ac.jp
Mon May 24 07:23:23 UTC 1999


  Hi,

> Doug Way wrote:
> > [ ... ]
> > According to Ohshima, Squeak 2.4 on Mac sometimes fails to create an
> > instance of FileStream.
> > It silently returns nil, instead of a FileStream. Maybe the failure
> > occurs in VM.
> > (I cannot check by myself, because I'm not a Mac user).
> 
> Since the file I/O system does not use exceptions, returning nil is the only way
> things like file opening can fail gracefully. Every method that opens a file
> should check the result against nil before proceeding.

  Yes, I agree that the user should check it on the current
implementation.

  The problem I thought of when I sent an email to
Umezawa-san was StandardFileStream>>open:forWrite: *sometimes*
returns nil (silently) *even if* just after
StandardFileStream class>>isAFileNamed: returning true.

  It seems to me that the following statement:
----------------------
(StandardFileStream isAFileNamed: fileName) ifTrue:
	[^ StandardFileStream new open: fileName forWrite: aBoolean].
----------------------
is considered to be an "idiom" to open a file without fail.
However, what isAFileNamed: does is to try to open a file
with open:forWrite: and to see the result (and close), and
virtually, the result is unpredictable.

                                             OHSHIMA Yoshiki
                Dept. of Mathematical and Computing Sciences
                               Tokyo Institute of Technology 

P.S.
  Umezawa-san, why don't you subscribe this mailling-list?





More information about the Squeak-dev mailing list