mkdtemp.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright (C) 1999, 2001-2003, 2006-2007, 2009-2013 Free Software
  2. Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. /* Extracted from misc/mkdtemp.c. */
  15. #include <config.h>
  16. /* Specification. */
  17. #include <stdlib.h>
  18. #include "tempname.h"
  19. /* Generate a unique temporary directory from XTEMPLATE.
  20. The last six characters of XTEMPLATE must be "XXXXXX";
  21. they are replaced with a string that makes the filename unique.
  22. The directory is created, mode 700, and its name is returned.
  23. (This function comes from OpenBSD.) */
  24. char *
  25. mkdtemp (char *xtemplate)
  26. {
  27. if (gen_tempname (xtemplate, 0, 0, GT_DIR))
  28. return NULL;
  29. else
  30. return xtemplate;
  31. }