Bug or feature in StandardFileStream
nicolas cellier
ncellier at ifrance.com
Sun Feb 12 14:38:34 UTC 2006
Le Dimanche 12 Février 2006 15:19, David T. Lewis a écrit :
> On Sun, Feb 12, 2006 at 12:02:21PM +0100, Martin Kuball wrote:
> > The following behaviour seems odd to me:
> >
> > file := StandardFileStream readOnlyFileNamed: 'test'.
> > file skip: self size.
> > file atEnd. (-> true, OK)
> >
> > file skip: 1.
> > file atEnd (-> false ???)
> >
> > My VM is rather old (> 1 year), so maybe someone should test this with
> > a more recent one.
>
> It's a feature. It just means that you can set the file position beyond
> end of file, at which point it is no longer "atEnd". You can use
> #setToEnd to position the file pointer to the actual end of file.
>
> If it did not work this way, you would have no way to (for example)
> write a single byte at position 1000 without first having written
> something to the preceding 999 positions. You probably don't want
> to do this very often, but at least it's possible.
>
> It works the same on Windows and Unix, so I expect that the behavior
> is consistent across all platforms.
>
> Dave
Maybe it's a usefull feature for files opened for writing, I don't know.
But Martin had its file opened readOnly, in which case such a feature makes no
sense.
What would file next will answer? an infinite collection of zeros like a null
stream ?
Everybody would prefer getting an Exception rather than this strange behavior
i guess.
More information about the Squeak-dev
mailing list
|