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

GIS library - Determine GRASS data base file name. More...

`#include <string.h>`
`#include <stdlib.h>`
`#include <grass/gis.h>`
`#include "gis_local_proto.h"`
Include dependency graph for file_name.c:

Go to the source code of this file.

## Functions

char * | G_file_name (char *path, const char *element, const char *name, const char *mapset)
| Builds full path names to GIS data files.
char * | G_file_name_misc (char *path, const char *dir, const char *element, const char *name, const char *mapset)
| Builds full path names to GIS misc data files.
char * | G_file_name_tmp (char *path, const char *element, const char *name, const char *mapset)
| Builds full path names to GIS data files in temporary directory (for internal use only).
char * | G_file_name_basedir (char *path, const char *element, const char *name, const char *mapset, const char *basedir)
| Builds full path names to GIS data files in temporary directory (for internal use only).

## Detailed Description

GIS library - Determine GRASS data base file name.

(C) 2001-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
  Original author CERL

Definition in file file_name.c.

## Function Documentation

## G_file_name()

char * G_file_name | ( | char * | path,
|  | const char * | element,
|  | const char * | name,
|  | const char * | mapset )

Builds full path names to GIS data files.

If name is of the form "nnn@ppp" then path is set as if name had been "nnn" and mapset had been "ppp" (mapset parameter itself is ignored in this case).

Paths to files are currently in form: /path/to/location/mapset/element/name

path input buffer memory must be allocated by caller.

C:

char path[GPATH_MAX];
G_file_name(path, "fcell", "my_raster", "my_mapset");
// path now is "/full/path/to/my_mapset/fcell/my_raster"
G_file_name
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
Definition file_name.c:61
path
Definition path.h:15

Python:

import ctypes
from grass.pygrass.utils import decode
from grass.lib.gis import G_file_name, GPATH_MAX
path = ctypes.create_string_buffer(GPATH_MAX)
path_str = decode(G_file_name(path, "elem", "name", "mapset"))
print(path_str)
>>> /full/path/to/mapset/elem/name

Parameters

  [out] | path | allocated buffer to hold resultant full path to file
  | element | database element (eg, "cell", "cellhd", "vector", etc)
  | name | name of file to build path to (fully qualified names allowed)
  | mapset | mapset name

Returns
  pointer to path buffer

Definition at line 61 of file file_name.c.

References name, and NULL.

Referenced by G_get_ellipsoid_parameters(), G_get_projepsg(), G_get_projinfo(), G_get_projsrid(), G_get_projunits(), G_get_projwkt(), G_has_vector_timestamp(), G_make_location(), G_make_location_epsg(), G_make_mapset_dir_object(), G_make_mapset_element(), G_make_mapset_object_group(), G_mapset_permissions(), G_myname(), G_rename(), G_tempfile_pid(), G_write_projsrid(), G_write_projwkt(), M__empty(), M_do_copy(), and main().

## G_file_name_basedir()

char * G_file_name_basedir | ( | char * | path,
|  | const char * | element,
|  | const char * | name,
|  | const char * | mapset,
|  | const char * | basedir )

Builds full path names to GIS data files in temporary directory (for internal use only).

By default the GRASS temporary directory is located at $LOCATION/$MAPSET/.tmp/$HOSTNAME/. If basedir is provided, the temporary directory is located at <basedir>/.tmp/$HOSTNAME/.

Parameters

  [out] | path | buffer to hold resultant full path to file
  | element | database element (eg, "cell", "cellhd", "vector", etc)
  | name | name of file to build path to (fully qualified names allowed)
  | mapset | mapset name
  | basedir |

Returns
  pointer to path buffer

Definition at line 155 of file file_name.c.

References name, and NULL.

Referenced by G_make_mapset_object_group_basedir(), and G_tempfile_pid_basedir().

## G_file_name_misc()

char * G_file_name_misc | ( | char * | path,
|  | const char * | dir,
|  | const char * | element,
|  | const char * | name,
|  | const char * | mapset )

Builds full path names to GIS misc data files.

Paths to misc files are currently in form: /path/to/location/mapset/dir/name/element

path input buffer memory must be allocated by caller.

C:

char path[GPATH_MAX];
G_file_name_misc(path, "cell_misc", "history", "my_raster", "my_mapset");
// path now contains "/full/path/to/my_mapset/cell_misc/my_raster/history"
G_file_name_misc
char * G_file_name_misc(char *path, const char *dir, const char *element, const char *name, const char *mapset)
Builds full path names to GIS misc data files.
Definition file_name.c:101

Python:

import ctypes
from grass.pygrass.utils import decode
from grass.lib.gis import G_file_name_misc, GPATH_MAX
path = ctypes.create_string_buffer(GPATH_MAX)
path_str = decode(G_file_name_misc(path, "dir", "elem", "name", "mapset"))
print(path_str)
>>> /full/path/to/mapset/dir/name/elem

Parameters

  [out] | path | allocated buffer to hold resultant full path to file
  | dir | misc directory (e.g., "cell_misc", "group")
  | element | database element (in this case – file to build path to e.g., "history", "REF")
  | name | name of object (raster, group; fully qualified names allowed e.g., "my_raster@PERMANENT")
  | mapset | mapset name

Returns
  pointer to path buffer

Definition at line 101 of file file_name.c.

References name, and NULL.

## G_file_name_tmp()

char * G_file_name_tmp | ( | char * | path,
|  | const char * | element,
|  | const char * | name,
|  | const char * | mapset )

Builds full path names to GIS data files in temporary directory (for internal use only).

By default temporary directory is located $LOCATION/$MAPSET/.tmp/$HOSTNAME. If GRASS_VECTOR_TMPDIR_MAPSET is set to "0", the temporary directory is located in TMPDIR (environmental variable defined by the user or GRASS initialization script if not given). Note that GRASS_VECTOR_TMPDIR_MAPSET variable is currently used only by vector library.

Parameters

  [out] | path | buffer to hold resultant full path to file
  | element | database element (eg, "cell", "cellhd", "vector", etc)
  | name | name of file to build path to (fully qualified names allowed)
  | mapset | mapset name

Returns
  pointer to path buffer

Definition at line 125 of file file_name.c.

References name, and NULL.

Referenced by G_make_mapset_element_tmp(), and G_make_mapset_object_group_tmp().