mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* posix.c (scm_tmpnam): check that return value from tmpnam is not
NULL. rewrote the docstring. (scm_mkstemp): new procedure implementing "mkstemp!". * posix.h: declare scm_mkstemp. * net_db.c: declare h_errno if configure didn't define HAVE_H_ERRNO. normally it would be found in netdb.h.
This commit is contained in:
parent
789ecc0581
commit
6d163216bd
4 changed files with 47 additions and 5 deletions
7
NEWS
7
NEWS
|
@ -401,6 +401,13 @@ Set/remove an advisory shared or exclusive lock on `file'.
|
|||
Set or get the hostname of the machine the current process is running
|
||||
on.
|
||||
|
||||
** New function: mkstemp! tmpl
|
||||
mkstemp creates a new unique file in the file system and returns a
|
||||
new buffered port open for reading and writing to the file. TMPL
|
||||
is a string specifying where the file should be created: it must
|
||||
end with `XXXXXX' and will be changed in place to return the name
|
||||
of the temporary file.
|
||||
|
||||
** New function: open-input-string string
|
||||
|
||||
Return an input string port which delivers the characters from
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
2001-03-18 Gary Houston <ghouston@arglist.com>
|
||||
|
||||
* posix.c (scm_tmpnam): check that return value from tmpnam is not
|
||||
NULL. rewrote the docstring.
|
||||
(scm_mkstemp): new procedure implementing "mkstemp!".
|
||||
* posix.h: declare scm_mkstemp.
|
||||
|
||||
* net_db.c: declare h_errno if configure didn't define HAVE_H_ERRNO.
|
||||
normally it would be found in netdb.h.
|
||||
|
||||
|
|
|
@ -1028,19 +1028,48 @@ SCM_DEFINE (scm_environ, "environ", 0, 1, 0,
|
|||
|
||||
SCM_DEFINE (scm_tmpnam, "tmpnam", 0, 0, 0,
|
||||
(),
|
||||
"Create a new file in the file system with a unique name. The return\n"
|
||||
"value is the name of the new file. This function is implemented with\n"
|
||||
"the @code{tmpnam} function in the system libraries.")
|
||||
"tmpnam returns a name in the file system that does not match\n"
|
||||
"any existing file. However there is no guarantee that\n"
|
||||
"another process will not create the file after tmpnam\n"
|
||||
"is called. Care should be taken if opening the file,\n"
|
||||
"e.g., use the O_EXCL open flag or use @code{mkstemp!} instead.")
|
||||
#define FUNC_NAME s_scm_tmpnam
|
||||
{
|
||||
char name[L_tmpnam];
|
||||
SCM_SYSCALL (tmpnam (name););
|
||||
char *rv;
|
||||
|
||||
SCM_SYSCALL (rv = tmpnam (name));
|
||||
if (rv == NULL)
|
||||
/* not SCM_SYSERROR since errno probably not set. */
|
||||
SCM_MISC_ERROR ("tmpnam failed", SCM_EOL);
|
||||
return scm_makfrom0str (name);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
#endif
|
||||
|
||||
SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0,
|
||||
(SCM tmpl),
|
||||
"mkstemp creates a new unique file in the file system and\n"
|
||||
"returns a new buffered port open for reading and writing to\n"
|
||||
"the file. @var{tmpl} is a string specifying where the\n"
|
||||
"file should be created: it must end with @code{XXXXXX}\n"
|
||||
"and will be changed in place to return the name of the\n"
|
||||
"temporary file.\n")
|
||||
#define FUNC_NAME s_scm_mkstemp
|
||||
{
|
||||
char *c_tmpl;
|
||||
int rv;
|
||||
|
||||
SCM_STRING_COERCE_0TERMINATION_X (tmpl);
|
||||
SCM_VALIDATE_STRING_COPY (1, tmpl, c_tmpl);
|
||||
SCM_SYSCALL (rv = mkstemp (c_tmpl));
|
||||
if (rv == -1)
|
||||
SCM_SYSERROR;
|
||||
return scm_fdes_to_port (rv, "w+", tmpl);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_DEFINE (scm_utime, "utime", 1, 2, 0,
|
||||
(SCM pathname, SCM actime, SCM modtime),
|
||||
"@code{utime} sets the access and modification times for\n"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#ifndef POSIXH
|
||||
#define POSIXH
|
||||
/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -85,6 +85,7 @@ extern SCM scm_fork (void);
|
|||
extern SCM scm_uname (void);
|
||||
extern SCM scm_environ (SCM env);
|
||||
extern SCM scm_tmpnam (void);
|
||||
extern SCM scm_mkstemp (SCM tmpl);
|
||||
extern SCM scm_open_pipe (SCM pipestr, SCM modes);
|
||||
extern SCM scm_close_pipe (SCM port);
|
||||
extern SCM scm_utime (SCM pathname, SCM actime, SCM modtime);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue