24 static int next(
char **replace,
int num_replace)
28 for (i = 0; i < num_replace; i++) {
41 static int G__mkstemp(
char *
template,
int flags,
int mode)
49 char *p = strchr(ptr,
'X');
52 replace[num_replace++] = p;
61 if (!next(replace, num_replace))
64 if (access(
template, F_OK) == 0)
70 fd = open(
template, flags, mode);
106 return G__mkstemp(
template, 0, 0) < 0 ?
NULL :
template;
130 switch (flags & O_ACCMODE) {
138 G_fatal_error(
_(
"Unrecognised access mode: %o"), flags & O_ACCMODE);
142 return G__mkstemp(
template, flags | O_CREAT | O_EXCL, mode);
164 const char *fmode = ((flags & O_ACCMODE) == O_RDWR)
165 ? ((flags & O_APPEND) ?
"a+" :
"w+")
166 : ((flags & O_APPEND) ?
"a" :
"w");
167 int fd =
G_mkstemp(
template, flags, mode);
170 return fdopen(fd, fmode);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
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.
char * G_mktemp(char *template)
Opens a temporary file.