[GRASS-user] windows format for temporary file path

Glynn Clements glynn at gclements.plus.com
Thu Mar 15 10:13:25 EDT 2012


Richard Edmonds wrote:

> On a google search for building a temporary path in a bash script for 
> win grass I found the manual for g.tempfile which lead me to write the line
> 
> temp1=`g.tempfile pid=$$`
> 
> which, on echo, generated E:\GRASSdata/newLocation/PERMANENT/.tmp/9168.0
> 
> and in use results in the following error:
> Illegal filename. Character </> not allowed.
> <E:\GRASSdata/newLocation/PERMANENT/.tmp/7512.0> is an illegal file name

In what context does the error occur?

> So, do I have to run sed or some such to convert the / to \? or is there 
> a windows safe way to generate a temporary file path? Or better yet an 
> OS agnostic way?

The problem isn't the backslashes. The error message:

	Illegal filename. Character </> not allowed.

implies that it's expecting a simple file name rather than a complete
path.

The error message matches that generated by G_legal_filename():

	fprintf(stderr,
		_("Illegal filename. Character <%c> not allowed.\n"), *s)

That function is used to validate the names of maps, mapsets,
locations, etc, where the name is used as a single component of the
path. It's possible that it's being used where it isn't appropriate
(i.e. where an absolute path is appropriate), but it's also possible
that you're passing an absolute path where a simple filename (or even
a map name) is actually required.

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


More information about the grass-user mailing list