1 | /* Create a temporary file or directory.
|
---|
2 |
|
---|
3 | Copyright (C) 2006 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 2, or (at your option)
|
---|
8 | 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, write to the Free Software Foundation,
|
---|
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
---|
18 |
|
---|
19 | /* header written by Eric Blake */
|
---|
20 |
|
---|
21 | /* In gnulib, always prefer large files. GT_FILE maps to
|
---|
22 | __GT_BIGFILE, not __GT_FILE, for a reason. */
|
---|
23 | #define GT_FILE 1
|
---|
24 | #define GT_DIR 2
|
---|
25 | #define GT_NOCREATE 3
|
---|
26 |
|
---|
27 | /* Generate a temporary file name based on TMPL. TMPL must match the
|
---|
28 | rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
|
---|
29 | does not exist at the time of the call to gen_tempname. TMPL is
|
---|
30 | overwritten with the result.
|
---|
31 |
|
---|
32 | KIND may be one of:
|
---|
33 | GT_NOCREATE: simply verify that the name does not exist
|
---|
34 | at the time of the call.
|
---|
35 | GT_FILE: create a large file using open(O_CREAT|O_EXCL)
|
---|
36 | and return a read-write fd. The file is mode 0600.
|
---|
37 | GT_DIR: create a directory, which will be mode 0700.
|
---|
38 |
|
---|
39 | We use a clever algorithm to get hard-to-predict names. */
|
---|
40 | extern int gen_tempname (char *tmpl, int kind);
|
---|