summaryrefslogtreecommitdiff
path: root/libguile/posix.c
diff options
context:
space:
mode:
authorThien-Thi Nguyen <ttn@gnuvola.org>2010-02-12 16:01:16 +0100
committerAndy Wingo <wingo@pobox.com>2010-06-15 23:06:00 +0200
commitcd53bd3668d7a8e36a53de3f12beaf9853cfb911 (patch)
tree38975e7d8ecf3dd40b00171cac4edeb8f011c78e /libguile/posix.c
parent1772145c0222e4826e5113c14ee96fd95b263420 (diff)
downloadguile-cd53bd3668d7a8e36a53de3f12beaf9853cfb911.tar.gz
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'.
Diffstat (limited to 'libguile/posix.c')
-rw-r--r--libguile/posix.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libguile/posix.c b/libguile/posix.c
index b228925f3..627647824 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -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),