1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +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:
Gary Houston 2001-03-18 20:29:58 +00:00
parent 789ecc0581
commit 6d163216bd
4 changed files with 47 additions and 5 deletions

View file

@ -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"