* Creating temporary files
@ 2013-03-20 13:39 msematman
2013-03-20 13:59 ` Daniel Hartwig
0 siblings, 1 reply; 2+ messages in thread
From: msematman @ 2013-03-20 13:39 UTC (permalink / raw)
To: guile-user
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 ?
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.
Am I using this utility in a wrong way? Is it obsoleted?
--
msematman@myopera.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Creating temporary files
2013-03-20 13:39 Creating temporary files msematman
@ 2013-03-20 13:59 ` Daniel Hartwig
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Hartwig @ 2013-03-20 13:59 UTC (permalink / raw)
To: msematman; +Cc: guile-user
On 20 March 2013 21:39, <msematman@myopera.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-20 13:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 13:39 Creating temporary files msematman
2013-03-20 13:59 ` Daniel Hartwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).