24 static int next(
char **replace,
int num_replace)
28 for (i = 0; i < num_replace; i++) {
42 static int G__mkstemp(
char *
template,
int flags,
int mode)
50 char *p = strchr(ptr,
'X');
54 replace[num_replace++] = p;
63 if (!next(replace, num_replace))
66 if (access(
template, F_OK) == 0)
72 fd = open(
template, flags, mode);
107 return G__mkstemp(
template, 0, 0) < 0 ?
NULL :
template;
131 switch (flags & O_ACCMODE) {
139 G_fatal_error(
_(
"Unrecognised access mode: %o"), flags & O_ACCMODE);
143 return G__mkstemp(
template, flags | O_CREAT | O_EXCL, mode);
165 const char *fmode = ((flags & O_ACCMODE) == O_RDWR)
166 ? ((flags & O_APPEND) ?
"a+" :
"w+")
167 : ((flags & O_APPEND) ?
"a" :
"w");
168 int fd =
G_mkstemp(
template, flags, mode);
172 return fdopen(fd, fmode);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
char * G_mktemp(char *template)
Opens a temporary file.
FILE * G_mkstemp_fp(char *template, int flags, int mode)
Returns a file descriptor.
int G_mkstemp(char *template, int flags, int mode)
Returns a file descriptor.