1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Add tmpfile(3) to libguile.

* libguile/posix.c (scm_tmpfile): New primitive.
* libguile/posix.h (scm_tmpfile): New func decl.

* doc/ref/posix.texi (File System): Document `tmpfile'.
This commit is contained in:
Thien-Thi Nguyen 2010-02-12 16:01:16 +01:00 committed by Andy Wingo
parent 1772145c02
commit cd53bd3668
3 changed files with 27 additions and 0 deletions

View file

@ -948,6 +948,15 @@ which is usual for ordinary file creation,
@end example
@end deffn
@deffn {Scheme Procedure} tmpfile
@deffnx {C Function} scm_tmpfile
Return an input/output port to a unique temporary file
named using the path prefix @code{P_tmpdir} defined in
@file{stdio.h}.
The file is automatically deleted when the port is closed
or the program terminates.
@end deffn
@deffn {Scheme Procedure} dirname filename
@deffnx {C Function} scm_dirname (filename)
Return the directory name component of the file name

View file

@ -1372,6 +1372,23 @@ SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0,
}
#undef FUNC_NAME
SCM_DEFINE (scm_tmpfile, "tmpfile", 0, 0, 0,
(void),
"Return an input/output port to a unique temporary file\n"
"named using the path prefix @code{P_tmpdir} defined in\n"
"@file{stdio.h}.\n"
"The file is automatically deleted when the port is closed\n"
"or the program terminates.")
#define FUNC_NAME s_scm_tmpfile
{
FILE *rv;
if (! (rv = tmpfile ()))
SCM_SYSERROR;
return scm_fdes_to_port (fileno (rv), "w+", SCM_BOOL_F);
}
#undef FUNC_NAME
SCM_DEFINE (scm_utime, "utime", 1, 5, 0,
(SCM pathname, SCM actime, SCM modtime, SCM actimens, SCM modtimens,
SCM flags),

View file

@ -68,6 +68,7 @@ SCM_API SCM scm_uname (void);
SCM_API SCM scm_environ (SCM env);
SCM_API SCM scm_tmpnam (void);
SCM_API SCM scm_mkstemp (SCM tmpl);
SCM_API SCM scm_tmpfile (void);
SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes);
SCM_API SCM scm_close_pipe (SCM port);
SCM_API SCM scm_utime (SCM pathname, SCM actime, SCM modtime,