[GRASS5] OVERWRITE
Glynn Clements
glynn at gclements.plus.com
Wed Dec 1 05:25:35 EST 2004
Radim Blazek wrote:
> New GRASS users are usually surprised that most GRASS modules silently
> or with warning overwrite existing maps. Most normal users
> however like this feature (AFAIK).
>
> Some modules have -o (overwrite) option ( e.g. r.composite, g.copy ).
> For vector maps it is possible to set OVERWRITE variable to 0
> to disable overwriting but default (if not set) is 1 (overwrite).
>
> My suggestion is:
> 1) use OVERWRITE GRASS variable also in G_open_cell_new,
> if OVERWRITE=0 and raster exists G_open_cell_new will call
> G_fatal_error (?, not sure)
> 2) change OVERWRITE default value to 0 (don't overwrite)
> 3) Add a new function G_force_overwrite which can force
> overwriting even if OVERWRITE=0. Modules with -o flag can use
> if ( flag_o->answer )
> G_force_overwrite();
> before calling G_open_cell_new
Arguably, the check should be done in G_parser() rather than
G_open_cell_new() etc. I.e. if the gisprompt field contains "new",
G_parser() would generate an error if the map/file already exists.
The reason being that a module could spend a long time processing
before it opens the output file.
OTOH, such modules could just be re-written to open the output file
earlier.
It isn't strictly necessary to provide an "overwrite" option; the user
can always run g.remove first.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list