global: convert indentation-TABs to spaces
[coreutils.git] / gl / lib / tempname.h
blobee34aca2192c2b322b9e0731f9aabf734590f34f
1 /* Create a temporary file or directory.
3 Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
18 /* header written by Eric Blake */
20 /* In gnulib, always prefer large files. GT_FILE maps to
21 __GT_BIGFILE, not __GT_FILE, for a reason. */
22 #define GT_FILE 1
23 #define GT_DIR 2
24 #define GT_NOCREATE 3
26 /* Generate a temporary file name based on TMPL. TMPL must match the
27 rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
28 does not exist at the time of the call to gen_tempname. TMPL is
29 overwritten with the result.
31 KIND may be one of:
32 GT_NOCREATE: simply verify that the name does not exist
33 at the time of the call.
34 GT_FILE: create a large file using open(O_CREAT|O_EXCL)
35 and return a read-write fd. The file is mode 0600.
36 GT_DIR: create a directory, which will be mode 0700.
38 We use a clever algorithm to get hard-to-predict names. */
39 #include <stddef.h>
40 extern int gen_tempname (char *tmpl, int kind);
41 extern int gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len);