diff options
Diffstat (limited to 'stdio-common/tmpfile64.c')
-rw-r--r-- | stdio-common/tmpfile64.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/stdio-common/tmpfile64.c b/stdio-common/tmpfile64.c index 5a6e323..5854f14 100644 --- a/stdio-common/tmpfile64.c +++ b/stdio-common/tmpfile64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,6 +19,9 @@ #include <errno.h> #include <stdio.h> +#ifdef _USE_IN_LIBIO +# define fdopen _IO_new_fdopen +#endif /* This returns a new stream opened on a temporary file (generated by tmpnam) The file is opened with mode "w+b" (binary read/write). @@ -27,23 +30,21 @@ FILE * tmpfile64 () { -#ifdef _G_OPEN64 char buf[FILENAME_MAX]; - char *filename; + int fd; FILE *f; - filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0, - (size_t *) NULL, &f, 1); - if (filename == NULL) + if (__path_search (buf, FILENAME_MAX, NULL, "tmpf")) + return NULL; + if ((fd = __gen_tempname (buf, 1, 1)) < 0) return NULL; /* Note that this relies on the Unix semantics that a file is not really removed until it is closed. */ - (void) remove (filename); + (void) remove (buf); + + if ((f = fdopen (fd, "w+b")) == NULL) + close (fd); return f; -#else - __set_errno (ENOSYS); - return NULL; -#endif } |