StandardFileStream>>truncate:

Avi Bryant avi.bryant at gmail.com
Fri Jun 3 18:51:31 UTC 2005


On 6/3/05, Chris Muller <chris at funkyobjects.org> wrote:
> Here's something to make you scratch your head.  When would the #size of
> aStandardFileStream ever change merely by closing and then opening the file?
> 
>         myFileStream size  "3300"
> 
>         myFileStream close; open
> 
>         myFileStream size  "50"
> 
> Ok, don't scratch; I've already done that.  The answer is when you #truncate:
> to 50 the file, it is not reflected by #size until the file is closed and
> reopened.

Hi Chris,

#size is generally unreliable - you can see the same effect if you use
another FileStream instance to append to the end of the file, for
example.  I had to modify OmniBase so that whenever the database needs
to know the size of the file it opens a readOnlyCopy, sends #size, and
immediately closes it.  Luckily this only needs to happen once per
commit and so the extra time this takes is ok.

This is only an issue on unix, btw - the Windows VM gets this right.

Avi



More information about the Squeak-dev mailing list