GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gis/open.c File Reference

GIS Library - open file functions. More...

#include <grass/config.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Include dependency graph for gis/open.c:

Go to the source code of this file.

Functions

int G_open_new (const char *element, const char *name)
 Open a new database file. More...
 
int G_open_old (const char *element, const char *name, const char *mapset)
 Open a database file for reading. More...
 
int G_open_update (const char *element, const char *name)
 Open a database file for update. More...
 
FILE * G_fopen_new (const char *element, const char *name)
 Open a new database file. More...
 
FILE * G_fopen_old (const char *element, const char *name, const char *mapset)
 Open a database file for reading. More...
 
FILE * G_fopen_append (const char *element, const char *name)
 Open a database file for update (append mode) More...
 
FILE * G_fopen_modify (const char *element, const char *name)
 Open a database file for update (r+ mode) More...
 

Detailed Description

GIS Library - open file functions.

(C) 1999-2008 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.

Author
USACERL and many others

Definition in file gis/open.c.

Function Documentation

FILE* G_fopen_append ( const char *  element,
const char *  name 
)

Open a database file for update (append mode)

The database file name under the element in the current mapset is opened for for writing. The UNIX fopen() routine, with "a" append mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (FILE *)
NULL could not open

Definition at line 252 of file gis/open.c.

References fd, and G_mapset().

FILE* G_fopen_modify ( const char *  element,
const char *  name 
)

Open a database file for update (r+ mode)

The database file name under the element in the current mapset is opened for for writing. The UNIX fopen() routine, with "r+" append mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (FILE *)
NULL

Definition at line 279 of file gis/open.c.

References fd, and G_mapset().

Referenced by V1_open_new_nat(), V1_open_old_nat(), and Vect__open_old().

FILE* G_fopen_new ( const char *  element,
const char *  name 
)

Open a new database file.

The database file name under the element in the current mapset is created and opened for writing (but not reading). The UNIX fopen() routine, with "w" write mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (FILE *)
NULL could not open

Definition at line 197 of file gis/open.c.

References fd, and G_mapset().

Referenced by G3d_writeCats(), G3d_writeHistory(), G__put_window(), G__quant_export(), G__write_cats(), G_oldsites_open_new(), G_put_3dview(), G_put_cell_title(), G_put_cellhd(), G_write_colors(), G_write_history(), I_put_group(), if(), V1_open_new_nat(), Vect__write_head(), and Vect_open_new().

FILE* G_fopen_old ( const char *  element,
const char *  name,
const char *  mapset 
)

Open a database file for reading.

The database file name under the element in the specified mapset is opened for reading (but not for writing). The UNIX fopen() routine, with "r" read mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
mapsetmapset name containing map name
Returns
open file descriptor (FILE *)
NULL could not open

Definition at line 226 of file gis/open.c.

References fd.

Referenced by G3d_readHistory(), G__get_window(), G__quant_import(), G__read_cats(), G_get_3dview(), G_get_cell_title(), G_get_cellhd(), G_get_dig_title(), G_oldsites_open_old(), G_put_cell_title(), G_read_history(), I_get_group(), S_read(), V1_open_old_nat(), V2_open_old_ogr(), Vect__open_old(), Vect__read_head(), Vect_cidx_open(), Vect_open_spatial_index(), and Vect_open_topo().

int G_open_new ( const char *  element,
const char *  name 
)

Open a new database file.

Creates name in the current mapset and opens it for write only.

The database file name under the element in the current mapset is created and opened for writing (but not reading). The UNIX open() routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the open() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (int)
-1 could not open

Definition at line 125 of file gis/open.c.

References G_mapset().

Referenced by G_write_fp_range().

int G_open_old ( const char *  element,
const char *  name,
const char *  mapset 
)

Open a database file for reading.

The database file name under the element in the specified mapset is opened for reading (but not for writing). The UNIX open() routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file descriptor from the open() is returned.

Parameters
elementdatabase element name
namemap file name
mapsetmapset containing map name
Returns
open file descriptor (int)
-1 could not open

Definition at line 147 of file gis/open.c.

Referenced by G3d_openCellOldNoHeader(), G__open_cell_old(), and if().

int G_open_update ( const char *  element,
const char *  name 
)

Open a database file for update.

The database file name under the element in the current mapset is opened for reading and writing. The UNIX open() routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the open() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (int)
-1 could not open

Definition at line 168 of file gis/open.c.

References fd, and G_mapset().