[Glass] Problems managing files from Pharo and GemStone

Richard Sargent richard.sargent at gemtalksystems.com
Wed Apr 16 11:56:26 PDT 2014


Mariano Martinez Peck wrote
> ...
> I wonder which is the better way to handle the real stream API.. I
> mean... if each time I do a #nextPutAll: with a string I need to send
> #encodeAsUTF8, that is not very fun. 

I agree. It's not fun. And it seems to me that we will need encoded stream
support in the GemStone product. Community contributions in this area would
be welcome. :-)



> I wonder if Johan's text converters or MultiByteBinaryOrTextStream could
> be used. Ideally we should have a stream API that allow us to
> transparently encode with certain encoding, right?
> 
> Anyway....is it OK to assume FileStream will be able to properly decode a
> UTF stored? Say I wrote a file like this:
> 
> myfile := GsFile openWrite: self filename.
> myfile nextPutAll: 'myRootObject' sixxString encodeAsUTF8.
> myfile close.
> 
> (or any other file created by Pharo encoded with UTF8 as well)
> 
> (FileStream oldFileNamed: self filename)
> 
> will the api of FileStream know how to read this? I ask because I found
> methods like #contentsAsUtf8 which made me doubt.

I don't know the answer to these. GS has a FileStreamPortable in the base. 
(I don't know whether the FileStream you refer to is a GLASS artefact or in
Pharo.)


At the present time, it remains "hard work" for you. I suggest a Stream
wrapper around GsFile to provide a subset API for the things you need, so
you don't have to add UTF-8 conversions everywhere in your code. e.g. a
Utf8ReadStream or perhaps a Utf8ReadWriteStream class. It doesn't have to
expose the entire GsFile API.




--
View this message in context: http://forum.world.st/Glass-Problems-managing-files-from-Pharo-and-GemStone-tp4754791p4754982.html
Sent from the GLASS mailing list archive at Nabble.com.


More information about the Glass mailing list