Blame gnulib/lib/mkdtemp.c

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