GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
|
GIS Library - Temporary file functions. More...
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Go to the source code of this file.
Macros | |
#define | MAX_REPLACE 5 |
Functions | |
char * | G_mktemp (char *template) |
Opens a temporary file. More... | |
int | G_mkstemp (char *template, int flags, int mode) |
Returns a file descriptor. More... | |
FILE * | G_mkstemp_fp (char *template, int flags, int mode) |
Returns a file descriptor. More... | |
GIS Library - Temporary file functions.
(C) 2014 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file mkstemp.c.
int G_mkstemp | ( | char * | template, |
int | flags, | ||
int | mode | ||
) |
Returns a file descriptor.
This routine opens the file and returns a descriptor.
The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical).
The functions does not use the PID, although the caller can do so.
In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist.
Definition at line 127 of file mkstemp.c.
Referenced by ami_single_temp_name().
FILE* G_mkstemp_fp | ( | char * | template, |
int | flags, | ||
int | mode | ||
) |
Returns a file descriptor.
This routine opens the file and returns a FILE*.
The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical).
The functions does not use the PID, although the caller can do so.
In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist.
char* G_mktemp | ( | char * | template | ) |
Opens a temporary file.
This routine opens the file.
The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical).
The functions does not use the PID, although the caller can do so.
In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist.
Note: G_mktemp() as such it is prone to race conditions (some other process may create that file after G_mktemp() returns).