| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents. returns #[72 101 108 108 111 32 87 111 114 108 100] instead of 'Hello World' Does anybody have a fix..? Stef ( editing FS chapter).
Looks like there is a confusion between binary and text stream Alexandre On 13 Sep 2011, at 11:09, Stéphane Ducasse wrote:
| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents. returns #[72 101 108 108 111 32 87 111 114 108 100]
instead of 'Hello World'
Does anybody have a fix..?
Stef ( editing FS chapter).
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
or strings and widestrings. Stef On Sep 13, 2011, at 4:11 PM, Alexandre Bergel wrote:
Looks like there is a confusion between binary and text stream
Alexandre
On 13 Sep 2011, at 11:09, Stéphane Ducasse wrote:
| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents. returns #[72 101 108 108 111 32 87 111 114 108 100]
instead of 'Hello World'
Does anybody have a fix..?
Stef ( editing FS chapter).
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Then you also need to specify an encoding. Otherwise it does not make sense for a FSReadStream to return a String. Strictly speaking the FSWriteStream shouldn't accept a String as input either. Lukas On 13 September 2011 16:36, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
or strings and widestrings.
Stef On Sep 13, 2011, at 4:11 PM, Alexandre Bergel wrote:
Looks like there is a confusion between binary and text stream
Alexandre
On 13 Sep 2011, at 11:09, Stéphane Ducasse wrote:
| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents.    returns    #[72 101 108 108 111 32 87 111 114 108 100]
instead of 'Hello World'
Does anybody have a fix..?
Stef ( editing FS chapter).
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel  http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- Lukas Renggli www.lukas-renggli.ch
Concerning the encoding problem I would say so too⦠But there's another "problem" with FS file streams, they are correctly programmed and have a 1 based index. Whereas existing FileStreams are 0 based (no clue why that..) As an example I remember that we could not dump MCZ files directly to FSFilestreams since the zip compressor relies on 0 based indexing⦠I guess we need a big refactoring for this to work completely.. cami On 2011-09-13, at 16:41, Lukas Renggli wrote:
Then you also need to specify an encoding. Otherwise it does not make sense for a FSReadStream to return a String.
Strictly speaking the FSWriteStream shouldn't accept a String as input either.
Lukas
On 13 September 2011 16:36, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
or strings and widestrings.
Stef On Sep 13, 2011, at 4:11 PM, Alexandre Bergel wrote:
Looks like there is a confusion between binary and text stream
Alexandre
On 13 Sep 2011, at 11:09, Stéphane Ducasse wrote:
| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents. returns #[72 101 108 108 111 32 87 111 114 108 100]
instead of 'Hello World'
Does anybody have a fix..?
Stef ( editing FS chapter).
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- Lukas Renggli www.lukas-renggli.ch
On 13 September 2011 16:41, Lukas Renggli <renggli@gmail.com> wrote:
Then you also need to specify an encoding. Otherwise it does not make sense for a FSReadStream to return a String.
Strictly speaking the FSWriteStream shouldn't accept a String as input either.
+1000 there should be a clear separation between binary and text. I think that mixing the code for text and binary modes in single class is a source of errors and confusion. The code: stream := (working / 'foo.txt') writeStream. should be something like: stream := (working / 'foo.txt') writeStream textStream. where textStream should answer the wrapper stream around the original stream, something like: textStream ^ UnicodeTextWriteStream on: self then when you do: stream nextPutAll: 'abc' the wrapper stream takes care about converting input string into bytearray and then passing it further to basic stream. Of course there could be an optimization, if input string are bytestring etc , but model should be separated.
Lukas
On 13 September 2011 16:36, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
or strings and widestrings.
Stef On Sep 13, 2011, at 4:11 PM, Alexandre Bergel wrote:
Looks like there is a confusion between binary and text stream
Alexandre
On 13 Sep 2011, at 11:09, Stéphane Ducasse wrote:
| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents.    returns    #[72 101 108 108 111 32 87 111 114 108 100]
instead of 'Hello World'
Does anybody have a fix..?
Stef ( editing FS chapter).
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel  http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- Lukas Renggli www.lukas-renggli.ch
-- Best regards, Igor Stasenko AKA sig.
Ok now who will do that? Stef On Sep 13, 2011, at 6:12 PM, Igor Stasenko wrote:
On 13 September 2011 16:41, Lukas Renggli <renggli@gmail.com> wrote:
Then you also need to specify an encoding. Otherwise it does not make sense for a FSReadStream to return a String.
Strictly speaking the FSWriteStream shouldn't accept a String as input either.
+1000
there should be a clear separation between binary and text. I think that mixing the code for text and binary modes in single class is a source of errors and confusion.
The code:
stream := (working / 'foo.txt') writeStream.
should be something like:
stream := (working / 'foo.txt') writeStream textStream.
where textStream should answer the wrapper stream around the original stream, something like:
textStream ^ UnicodeTextWriteStream on: self
then when you do:
stream nextPutAll: 'abc'
the wrapper stream takes care about converting input string into bytearray and then passing it further to basic stream. Of course there could be an optimization, if input string are bytestring etc , but model should be separated.
Lukas
On 13 September 2011 16:36, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
or strings and widestrings.
Stef On Sep 13, 2011, at 4:11 PM, Alexandre Bergel wrote:
Looks like there is a confusion between binary and text stream
Alexandre
On 13 Sep 2011, at 11:09, Stéphane Ducasse wrote:
| working stream | working := FSFilesystem disk workingDirectory. stream := (working / 'foo.txt') writeStream. stream nextPutAll: 'Hello World'. stream close. stream := (working / 'foo.txt') readStream. stream contents. returns #[72 101 108 108 111 32 87 111 114 108 100]
instead of 'Hello World'
Does anybody have a fix..?
Stef ( editing FS chapter).
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- Lukas Renggli www.lukas-renggli.ch
-- Best regards, Igor Stasenko AKA sig.
participants (5)
-
Alexandre Bergel -
Camillo Bruni -
Igor Stasenko -
Lukas Renggli -
Stéphane Ducasse