Apples to Oranges in FileStream

Kevin Fisher kfisher at rim.net
Fri Aug 21 03:34:32 UTC 1998


Hello again:

Forgive me if I'm making another boneheaded newbie move here... :)  It has
been a while since I've touched Smalltalk and even before I was only in
the 'just learning' stage of things.  Squeak has re-ignited my interest.

I've been tutoring myself from the purple book, and creating some classes
to do various newbieish things.  My latest experiment is with FileStreams.
I am trying to open a new file and mark it for Reading and Writing ie:

fileStream := FileStream newFileNamed: 'some.file'.
fileStream readWrite


However, upon execution, I get an error within the FileStream>>readWrite
method.  The method sends:

readWrite
	self setMode: Read + Write

where Read + Write is some SmallInteger class variable.

The problem is in the FileStream>>setMode method:

setMode: m
	rwmode = m
	ifFalse: [(rwmode == nil or: [(rwmode bitAnd: Write) = 0 .....


The rwmode bitAnd: Write is what fails...rwmode does not understand
the bitAnd: message.

The rwmode instance variable is set in the concreteStream, which
is StandardFileStream.  When StandardFileStream creates a new file, it
sets rwmode to a Boolean, in the StandardFileStream>>open:forWrite:
method.  Hence, apples to oranges...the Boolean has no bitAnd: method!

Note that I also have tried opening a file for read using:

fileStream := FileStream fileNamed: 'some.file'
fileStream readOnly

without any difficulty (ie no errors with the readOnly message).  In fact,
it looks like the same sort of sequence is followed for the readOnly
message, except that it works!  Argh!

Any ideas?  Did I mention that I love Squeak? :)  I probably should get
more sleep before playing with it though...





More information about the Squeak-dev mailing list