Hum, use this instead:

Usage:

"Saving"
self persistAsSton: someDataStructure toFile: 'persist.dat'

"Loading"
someDataStructure := self loadStonFromFile: 'persist:dat'

Well, depends if you want to write to same file, different file etc, but
this will get you on the right track

On Wed, Nov 2, 2016 at 5:20 PM, p...@highoctane.be <p...@highoctane.be>
wrote:

> Use these methods in your class.
>
> loadStonFromFile: aDataFilenameString
>
> | data |
> data := STON fromStream: ((self dataFileNamed: aFilenameString)
> readStream).
> ^data
> persistAsSton: anObject toFile: aDataFilenameString (self
> newDataFileNamed: aFilenameString) writeStreamDo: [ :out | out << (STON
> toString: anObject) ]
>
>
> dataFileNamed: filename
>
> "For an existing file"
> ^ (FileLocator imageDirectory / 'data' / filename) fullPath asFileReference
>
>
> newDataFileNamed: filename
> | file |
> file := (FileLocator imageDirectory / 'data' / filename ) fullPath
> asFileReference.
> file writeStream close.
> ^ file
>
>
> Usage:
>
> "Saving"
> self persistAsSton: someDataStructure toFile: self newDataFileNamed:
> 'persist.dat'
>
> "Loading"
> someDataStructure := self loadStonFromFile: self dataFileNamed:
> 'persist:dat'
>
> HTH
>
> Phil
>
>
>
>
>
>
>
>
> On Wed, Nov 2, 2016 at 3:38 PM, Sven Van Caekenberghe <s...@stfx.eu>
> wrote:
>
>>
>> > On 2 Nov 2016, at 15:29, sergio ruiz <sergio....@gmail.com> wrote:
>> >
>> > Hmm… i need to look at this ..
>> >
>> > i can just burp out all my objects with ston and suck them back in on
>> the local machine..
>>
>> Just try it ;-)
>>
>>   STON put: myObjects onStream[Pretty]: fileStream.
>>
>>   STON fromStream: fileStream.
>>
>> https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBo
>> ok/lastSuccessfulBuild/artifact/book-result/STON/STON.html
>>
>> STON has already seen quite some usage, so you should be good.
>>
>> > On November 2, 2016 at 10:25:51 AM, p...@highoctane.be (
>> p...@highoctane.be) wrote:
>> >
>> >> Keeping data in image with a STON export would be good enough:
>> > ----
>> > peace,
>> > sergio
>> > photographer, journalist, visionary
>> >
>> > Public Key: http://bit.ly/29z9fG0
>> > #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
>> > http://www.Village-Buzz.com
>> > http://www.ThoseOptimizeGuys.com
>> > http://www.coffee-black.com
>> > http://www.painlessfrugality.com
>> > http://www.twitter.com/sergio_101
>> > http://www.facebook.com/sergio101
>>
>>
>>
>>
>

Reply via email to