GRASS GIS 7 Programmer's Manual
7.0.2(2015)-r00000
|
GIS Library - Temporary file functions. More...
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <grass/gis.h>
#include "local_proto.h"
Go to the source code of this file.
Functions | |
void | G_init_tempfile (void) |
Initialize environment for creating tempfiles. More... | |
char * | G_tempfile (void) |
Returns a temporary file name. More... | |
char * | G_tempfile_pid (int pid) |
Create tempfile from process id. More... | |
void | G_temp_element (char *element) |
Populates element with a path string. More... | |
GIS Library - Temporary file functions.
(C) 2001-2009 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 tempfile.c.
void G_init_tempfile | ( | void | ) |
Initialize environment for creating tempfiles.
Definition at line 27 of file tempfile.c.
References G_init_counter(), G_initialize_done(), and G_is_initialized().
Referenced by G_init_all(), and G_tempfile_pid().
void G_temp_element | ( | char * | element | ) |
Populates element with a path string.
[out] | element | element name |
Definition at line 98 of file tempfile.c.
References G__machine_name(), G_make_mapset_element(), and NULL.
Referenced by G_tempfile_pid(), and main().
char* G_tempfile | ( | void | ) |
Returns a temporary file name.
This routine returns a pointer to a string containing a unique temporary file name that can be used as a temporary file within the module. Successive calls to G_tempfile() will generate new names. Only the file name is generated. The file itself is not created. To create the file, the module must use standard UNIX functions which create and open files, e.g., creat() or fopen().
Successive calls will generate different names the names are of the form pid.n where pid is the programs process id number and n is a unique identifier.
Note: It is recommended to unlink() (remove) the temp file on exit/error. Only if GRASS is left with 'exit', the GIS mapset management will clean up the temp directory (ETC/clean_temp).
Definition at line 60 of file tempfile.c.
References G_tempfile_pid().
char* G_tempfile_pid | ( | int | pid | ) |
Create tempfile from process id.
See G_tempfile().
pid |
Definition at line 73 of file tempfile.c.
References G_counter_next(), G_file_name(), G_init_tempfile(), G_mapset(), G_store(), G_temp_element(), and name.
Referenced by G_tempfile().