[GRASS-dev] [GRASS GIS] #2475: g.findfile type/element support not clear

GRASS GIS trac at osgeo.org
Fri Nov 7 02:49:46 PST 2014

#2475: g.findfile type/element support not clear
 Reporter:  wenzeslaus                                                                                    |       Owner:  grass-dev@…              
     Type:  defect                                                                                        |      Status:  new                      
 Priority:  normal                                                                                        |   Milestone:  7.0.0                    
Component:  Default                                                                                       |     Version:  unspecified              
 Keywords:  g.findfile, find_file, types, elements, cell, fcell, dcell, rast, rast3d, API change, g.list  |    Platform:  Unspecified              
      Cpu:  Unspecified                                                                                   |  

Comment(by glynn):

 Replying to [comment:2 wenzeslaus]:

 > If I'm interested in the files, then I run `g.findfile`. If I'm
 searching DCELL raster, I ask for `elemenet=dcell`,

 That won't work. There is no "dcell" elements; the data file for floating-
 point maps is stored in fcell/<name> regardless of precision. Also, all
 raster maps have a "cell" element; it's just empty for floating-point and
 reclass maps.

 > but if I'm interested in searching for CELL, I got uncertain result
 because the map I found might be CELL as well as FCELL or DCELL.

 GRASS doesn't directly provide any functionality to search for maps
 satisfying criteria more specific than the mapset or type (raster or

 > So what is the `g.findfile` actually good for?

 g.findfile primarily makes G_find_file() available to scripts.

 It's used for finding whether something exists, in which mapset it exists,
 and the actual filename for a particular element.

 > And since `g.findfile` has the strange interface, wouldn't be better to
 use `g.list` for checking if map exists and getting its mapset?

 Using g.list is more expensive; potentially much more expensive if the
 mapset contains a large number of maps or is on a remote filesystem.

 Also, enumeration requires read permission on the directory, whereas
 accessing specific files only requires execute permission. This probably
 won't be an issue for GRASS databases, but the general principle is worth
 remembering (e.g. it's not uncommon for servers to use default directory
 permissions of 0751 = "drwxr-x--x" so that unprivileged users can use what
 they actually need but can't "explore" the filesystem).

Ticket URL: <http://trac.osgeo.org/grass/ticket/2475#comment:3>
GRASS GIS <http://grass.osgeo.org>

More information about the grass-dev mailing list