GRASS GIS 8 Programmer's Manual 8.4.1(2025)-45ca3179ab
|
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. | |
int | G_mkstemp (char *template, int flags, int mode) |
Returns a file descriptor. | |
FILE * | G_mkstemp_fp (char *template, int flags, int mode) |
Returns a file descriptor. | |
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 128 of file mkstemp.c.
References G_fatal_error().
Referenced by ami_single_temp_name(), and G_mkstemp_fp().
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.
Definition at line 163 of file mkstemp.c.
References G_mkstemp(), and NULL.
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).
Definition at line 105 of file mkstemp.c.
References NULL.