guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating temporary files


From: Daniel Hartwig
Subject: Re: Creating temporary files
Date: Wed, 20 Mar 2013 21:59:05 +0800

On 20 March 2013 21:39,  <address@hidden> wrote:
> I am somewhat confused by the behaviour of 'tmpfile' function in guile
> 2.0.5
>
> For example,
>
> (define a (tmpfile))
> (port-filename a)
>
> returns #f. Shouldn't there be a file created in /tmp ?

This POSIX procedure probably unlinks the file immediately after
creation, so that other processes could not access it without being
passed the open descriptor.  If you need to create a named temporary
file try ‘mkstemp!’.

>
> Using 'write-line' and 'read-line' from the module 'rdelim' to store and
> access the contents of 'a' is not working. One can write stuff in, but
> 'read-line' always
> returns an 'eof' object. I tried rewinding the file by using
> 'set-port-line!' and it still did not work.

‘set-port-line!’ does not change the cursor position, it only sets the
value that will be returned by a subsequent call to ‘port-line’.
Think of it as bookkeeping.  To really move the cursor you must use
‘seek’, e.g. ‘(seek a 0 SEEK_SET)’ to return to the start.

Regards



reply via email to

[Prev in Thread] Current Thread [Next in Thread]