COOPY » Guide
version 0.6.5
|
00001 /* Create a temporary file or directory. 00002 00003 Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc. 00004 00005 This program is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00017 00018 /* header written by Eric Blake */ 00019 00020 #ifndef GL_TEMPNAME_H 00021 # define GL_TEMPNAME_H 00022 00023 # include <stdio.h> 00024 00025 # ifdef __GT_FILE 00026 # define GT_FILE __GT_FILE 00027 # define GT_DIR __GT_DIR 00028 # define GT_NOCREATE __GT_NOCREATE 00029 # else 00030 # define GT_FILE 0 00031 # define GT_DIR 1 00032 # define GT_NOCREATE 2 00033 # endif 00034 00035 /* Generate a temporary file name based on TMPL. TMPL must match the 00036 rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). 00037 The name constructed does not exist at the time of the call to 00038 gen_tempname. TMPL is overwritten with the result. 00039 00040 KIND may be one of: 00041 GT_NOCREATE: simply verify that the name does not exist 00042 at the time of the call. 00043 GT_FILE: create a large file using open(O_CREAT|O_EXCL) 00044 and return a read-write fd. The file is mode 0600. 00045 GT_DIR: create a directory, which will be mode 0700. 00046 00047 We use a clever algorithm to get hard-to-predict names. */ 00048 extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind); 00049 00050 #endif /* GL_TEMPNAME_H */