Apples to Oranges in FileStream

Michael Donegan invader at zilker.net
Fri Aug 21 04:34:21 UTC 1998


The three class variables: Read, Write and Shorten are not initialized, so
I would steer clear of the readOnly, readWrite, readWriteShorten and
writeShorten
methods until all that gets straightened. Looks like an extension that
isn't done yet.

Someone is apparently trying to correct the problem that writable files
don't get truncated.

Squeak is great, but it has a few pitfalls when you actually try to get
something done. PositionableStream>>nextNumber: and nextInt32 have similar
problems with
missing asInteger after a self next.

        mkd

>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