[Pharo-users] Temporary files

Cyril Ferlicot Delbecque cyril.ferlicot at gmail.com
Wed May 11 09:09:50 EDT 2016



On 11/05/2016 15:01, Valentin Ryckewaert wrote:
> Hello everyone,
> 
> I would like to use a temporary file for a project and I didn't find an
> existing method.
> I'm asking my self if it's a better idea to use ffi or OSSubProcess (or
> something already build for it) to build a method able to create this
> tmp file.
> Someone could help me please?
> 
> PS : Should it be a good idea to add this method directly in Pharo ?

Hi,

For temporary files you can create a new file in memory via `FileSystem
memory` so you do not pollute your file system and the file will be
deleted later since the memory is volatile.

`file := FileSystem memory / 'tmp.txt'.
file ensureCreateFile.
file writeStreamDo: [ :s | s nextPutAll: 'Hello World' ].`

-- 
Cyril Ferlicot

http://www.synectique.eu

165 Avenue Bretagne
Lille 59000 France

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160511/3cc7cc83/attachment.asc>


More information about the Pharo-users mailing list