Appending to FileStream (update)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Appending to FileStream (update)

Ian Bartholomew-8
A little while ago (16th March) I mentioned that there was a problem with
appending bytes to a FileStream opened in binary mode. I've just discovered
that it affects all FileStream appends if the longhand form of the creation
method is used -

fs := FileStream write: 'test.txt'.
[fs nextPutAll: 'hello'] ensure: [fs close].

fs := FileStream write: 'test.txt' mode: #append check: false text: true.
[fs nextPutAll: ' world'] ensure: [fs close].

fs := FileStream read: 'test.txt'.
[fs contents inspect] ensure: [fs close].

answers ' world' rather than the expected 'hello world'

Lots of ways to work round it though so it's no great obstacle.

Ian