Hi guys,

due to last week's discussions and some comments in the issue tracker, I
wrote this morning the little improvement of the day: A simple
BinaryFileStream. That is:

A file stream that is
  - simple (no character encoding, no buffering)
  - binary (no automatic transformation to ascii characters)

The good thing is that these features are not lost: this file stream is
composable with Zn stream decorators:

"encoding"
fileStream := BinaryFileStream openFileNamed: 'test.txt'.
writeStream := ZnCharacterWriteStream on: fileStream.
writeStream nextPutAll: 'aáèOûï'.
writeStream nextPut: $a.

fileStream := BinaryFileStream openFileNamed: 'test.txt'.
readStream := ZnCharacterReadStream on: fileStream.
readStream upToEnd.

"Buffering"
fileStream := BinaryFileStream openFileNamed: 'test.txt'.
readStream := ZnBufferedReadStream on:(ZnCharacterReadStream on:
fileStream).
readStream upToEnd.

On the other side, this stream does not handle UI (like the old FileStream
that e.g., asks the user if a file already exists), since I believe this is
a concern that should be of the tools and not the file stream ^^.

This is related to issue 15486. A slice is in the inbox for it if you would
like to try.

Guille

Reply via email to