Browse Source

Added function 'mkdtemp' for Linux Test Project.

"Steven J. Hill" 22 years ago
parent
commit
55f46cc387
2 changed files with 37 additions and 1 deletions
  1. 1 1
      libc/stdlib/Makefile
  2. 36 0
      libc/stdlib/mkdtemp.c

+ 1 - 1
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 \

+ 36 - 0
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;
+}