Loading...
Searching...
No Matches
open.c File Reference

GIS Library - Open file functions. More...

`#include <grass/config.h>`
`#include <errno.h>`
`#include <string.h>`
`#include <unistd.h>`
`#include <fcntl.h>`
`#include <grass/gis.h>`
`#include <grass/glocale.h>`
`#include "gis_local_proto.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.
int | G_open_old (const char *element, const char *name, const char *mapset)
| Open a database file for reading.
int | G_open_update (const char *element, const char *name)
| Open a database file for update.
FILE * | G_fopen_new (const char *element, const char *name)
| Open a new database file.
FILE * | G_fopen_old (const char *element, const char *name, const char *mapset)
| Open a database file for reading.
FILE * | G_fopen_append (const char *element, const char *name)
| Open a database file for update (append mode).
FILE * | G_fopen_modify (const char *element, const char *name)
| Open a database file for update (r+ mode).

## Detailed Description

GIS Library - Open file functions.

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

## G_fopen_append()

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

  element | database element name
  name | map file name

Returns
  open file descriptor (FILE *)
  NULL on error

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

References err(), G_debug(), G_mapset(), G_warning(), name, and NULL.

## G_fopen_modify()

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

  element | database element name
  name | map file name

Returns
  open file descriptor (FILE *)
  NULL on error

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

References err(), G_debug(), G_mapset(), G_warning(), name, and NULL.

## G_fopen_new()

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

  element | database element name
  name | map file name

Returns
  open file descriptor (FILE *)
  NULL on error

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

References G_debug(), G_mapset(), and name.

Referenced by G_put_3dview(), G_put_element_window(), and G_write_vector_timestamp().

## G_fopen_old()

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

  element | database element name
  name | map file name
  mapset | mapset name containing map name

Returns
  open file descriptor (FILE *)
  NULL on error

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

References G_debug(), name, and NULL.

Referenced by G__get_list_of_mapsets(), G_get_3dview(), G_get_element_window(), G_read_vector_timestamp(), and S_read().

## G_open_new()

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

  element | database element name
  name | map file name

Returns
  open file descriptor (int)
  -1 could not open

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

References G_mapset(), and name.

## G_open_old()

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

  element | database element name
  name | map file name
  mapset | mapset containing map name

Returns
  open file descriptor (int)
  -1 could not open

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

References name.

## G_open_update()

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

  element | database element name
  name | map file name

Returns
  open file descriptor (int)
  -1 could not open

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

References err(), G_mapset(), G_warning(), and name.