GRASS 8 Programmer's Manual
8.5.0(2026)-8d6ceba290
Toggle main menu visibility
Loading...
Searching...
No Matches
overwrite.c
Go to the documentation of this file.
1
/*!
2
* \file lib/gis/overwrite.c
3
*
4
* \brief GIS Library - Check for overwrite.
5
*
6
* (C) 2001-2008, 2010 by the GRASS Development Team
7
*
8
* This program is free software under the GNU General Public License
9
* (>=v2). Read the file COPYING that comes with GRASS for details.
10
*
11
* \author GRASS Development Team, Martin Landa <landa.martin gmail.com>
12
*/
13
14
#include <stdlib.h>
15
#include <string.h>
16
#include <grass/gis.h>
17
18
/*!
19
* \brief Check for overwrite mode
20
*
21
* Check variables OVERWRITE, GRASS_OVERWRITE and '--o' flag.
22
*
23
* The parser G_parser() checks if the map already exists in current mapset,
24
* we can switch out the check and do it
25
* in the module after the parser.
26
*
27
* \param argc number of arguments
28
* \param argv array of arguments
29
*
30
* \return 1 if overwrite
31
* \return 0 if not overwrite
32
*/
33
int
G_check_overwrite
(
int
argc,
char
**argv)
34
{
35
const
char
*overstr;
36
int
overwrite;
37
38
overwrite = 0;
39
if
((overstr =
G_getenv_nofatal
(
"OVERWRITE"
))) {
40
overwrite = atoi(overstr);
41
}
42
43
/* check if inherited GRASS_OVERWRITE is 1 */
44
if
(!overwrite && (overstr = getenv(
"GRASS_OVERWRITE"
))) {
45
overwrite = atoi(overstr);
46
}
47
48
/* check for --o or --overwrite option */
49
if
(!overwrite) {
50
int
i;
51
52
for
(i = 0; i < argc; i++) {
53
if
(strcmp(argv[i],
"--o"
) == 0 ||
54
strcmp(argv[i],
"--overwrite"
) == 0) {
55
overwrite = 1;
56
break
;
57
}
58
}
59
}
60
61
G_setenv_nogisrc
(
"OVERWRITE"
,
"1"
);
62
63
return
overwrite;
64
}
G_getenv_nofatal
const char * G_getenv_nofatal(const char *name)
Get environment variable.
Definition
env.c:405
G_setenv_nogisrc
void G_setenv_nogisrc(const char *name, const char *value)
Set environment name to value (doesn't update .gisrc).
Definition
env.c:472
G_check_overwrite
int G_check_overwrite(int argc, char **argv)
Check for overwrite mode.
Definition
overwrite.c:33
gis
overwrite.c
Generated on
for GRASS 8 Programmer's Manual by
1.17.0