[GRASS-dev] illegal characters in filenames

Glynn Clements glynn at gclements.plus.com
Thu Dec 14 06:09:30 EST 2006


Andreas Gros wrote:

> while programming a grass module I would like to open some raster input files.

Are you talking about map names or file pathnames?

> Doing it the way as it's done in the r.example I get the following messages, 
> (which I'd like to avoid):

> Illegal filename. character </> not allowed.
> 
> GRASS_INFO_WARNING(5821,1): unable to find 
> [/home/andi/uni/da/prog/grassdb/metapop_test/PERMANENT/.tmp/hobbes/5821.0] in 
> [PERMANENT]

If you are referring to file pathnames, don't pass them to
G_legal_filename(); that function is specifically for validating the
names of maps (i.e. files within the GRASS database).

> When i open one of the raster files before in the grass-UI, I get the message 
> the "@" in metapop_test_rastersomething at PERMANENT is a prohibited character.

The argument to G_legal_filename() needs to be an unqualified map name
(i.e. with no @mapset part). It isn't legal to use the map at mapset
syntax for an output map; output maps are always created in the
current mapset.

In most cases, modules don't need to explicitly validate map names. 
For input maps, the name will have been validated when the map was
created, while output maps will have the name validated by the call to
G_open_raster_new().

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list