[GRASS5] OVERWRITE

Radim Blazek blazek at itc.it
Fri Dec 3 06:14:47 EST 2004


Glynn Clements wrote:
> 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.

In G_parser() it is impossible to use overwrite flag.

> 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.

Yes, but it is convenient. For now g.remove occasionally we can add -o 
to modules.

Radim





More information about the grass-dev mailing list