diff options
author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2002-09-04 02:45:42 +0000 |
---|---|---|
committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2002-09-04 02:45:42 +0000 |
commit | 55f46cc3874659f126a1151a51781b142eeac88a (patch) | |
tree | 2410d921f7b656b493d76a73347c965fc6358a5b | |
parent | 4f726510eb51706fb3c35e78f22c36ae3323a3c7 (diff) |
Added function 'mkdtemp' for Linux Test Project.
-rw-r--r-- | libc/stdlib/Makefile | 2 | ||||
-rw-r--r-- | libc/stdlib/mkdtemp.c | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index 99a267056..91a855f6f 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -41,7 +41,7 @@ endif MSRC2=atexit.c MOBJ2=atexit.o on_exit.o __exit_handler.o exit.o -CSRC = abort.c getenv.c mktemp.c realpath.c mkstemp.c mkstemp64.c \ +CSRC = abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \ rand.c random.c random_r.c setenv.c system.c div.c ldiv.c \ getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48.c \ drand48-iter.c drand48_r.c erand48.c erand48_r.c jrand48.c \ diff --git a/libc/stdlib/mkdtemp.c b/libc/stdlib/mkdtemp.c new file mode 100644 index 000000000..e1ece812f --- /dev/null +++ b/libc/stdlib/mkdtemp.c @@ -0,0 +1,36 @@ +/* vi: set sw=4 ts=4: */ +/* Copyright (C) 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> +#include "../misc/internals/tempname.h" + +/* Generate a unique temporary directory name from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the filename unique. + The directory is created, mode 700, and its name is returned. + (This function comes from OpenBSD.) */ +char * mkdtemp (char *template) +{ + if (__gen_tempname (template, __GT_DIR)) + /* We return the null string if we can't find a unique file name. */ + template[0] = '\0'; + + return template; +} |