Temporary files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Temporary files

Valentin Ryckewaert
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 ?
Reply | Threaded
Open this post in threaded view
|

Re: Temporary files

CyrilFerlicot


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


signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Temporary files

Sven Van Caekenberghe-2
In reply to this post by Valentin Ryckewaert
Check out FileReference class>>#newTempFilePrefix:suffix:

> On 11 May 2016, at 15:01, Valentin Ryckewaert <[hidden email]> 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 ?