summaryrefslogtreecommitdiff
path: root/libc/stdlib/mkdtemp.c
diff options
context:
space:
mode:
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
commit55f46cc3874659f126a1151a51781b142eeac88a (patch)
tree2410d921f7b656b493d76a73347c965fc6358a5b /libc/stdlib/mkdtemp.c
parent4f726510eb51706fb3c35e78f22c36ae3323a3c7 (diff)
Added function 'mkdtemp' for Linux Test Project.
Diffstat (limited to 'libc/stdlib/mkdtemp.c')
-rw-r--r--libc/stdlib/mkdtemp.c36
1 files changed, 36 insertions, 0 deletions
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;
+}