New module 'mkostemp'.
[gnulib.git] / lib / tempname.h
1 /* Create a temporary file or directory.
2
3    Copyright (C) 2006, 2009 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 /* header written by Eric Blake */
19
20 #define GT_FILE         1
21 #define GT_DIR          2
22 #define GT_NOCREATE     3
23
24 /* Generate a temporary file name based on TMPL.  TMPL must match the
25    rules for mk[s]temp (i.e. end in "XXXXXX").  The name constructed
26    does not exist at the time of the call to gen_tempname.  TMPL is
27    overwritten with the result.
28
29    KIND may be one of:
30    GT_NOCREATE:         simply verify that the name does not exist
31                         at the time of the call.
32    GT_FILE:             create a large file using open(O_CREAT|O_EXCL)
33                         and return a read-write fd.  The file is mode 0600.
34    GT_DIR:              create a directory, which will be mode 0700.
35
36    We use a clever algorithm to get hard-to-predict names. */
37 extern int gen_tempname (char *tmpl, int flags, int kind);