[Pharo-users] Lost in stream

Hilaire hilaire at drgeo.eu
Sat Jun 16 04:27:41 EDT 2018


Sometime you just need a good sleep, which I was fortunate to have.

My newer code append contents to existing file, so it lead to corrupted 
files at the end. Ensuring it is deleted first solved the problem:

(location  asFileReference / filename) ensureDelete binaryWriteStreamDo: 
[ :fileStream |
        fileStream nextPutAll: stream contents]

There is still the issue of XML entity I described in an previous email, 
the impact is minor for Dr. Geo though. Do other have issues with that?

Hilaire


Le 15/06/2018 à 18:31, Hilaire a écrit :
> This fromer code to save file (xml or PNG file):
>
> " |streamOnDisk|
>     [streamOnDisk := MultiByteFileStream forceNewFileNamed: (self 
> absolutePath: filename).
>     streamOnDisk nextPutAll: stream contents] ensure:
>         [streamOnDisk close]"
>
> and the newer one:
>
>     (location  asFileReference / filename) binaryWriteStreamDo: [ 
> :fileStream |
>         fileStream nextPutAll: stream contents]
>
> The new one produce both wrong XML file and PNG file. The file looks 
> short cuted at the end.

-- 
Dr. Geo
http://drgeo.eu





More information about the Pharo-users mailing list