GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
mke_mapset.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <sys/types.h>
5
#include <sys/stat.h>
6
#include <fcntl.h>
7
#include <unistd.h>
8
#include <errno.h>
9
extern
int
errno
;
10
11
#include <grass/gis.h>
12
13
int
make_mapset
(
const
char
*location,
const
char
*mapset)
14
{
15
char
buffer[GPATH_MAX];
16
char
*buffer2;
17
FILE *fd;
18
struct
Cell_head window;
19
20
/* create the mapset directory */
21
sprintf(buffer,
"%s/%s"
, location, mapset);
22
G_mkdir
(buffer);
23
24
/* give the mapset a default window for the entire location */
25
G_get_default_window
(&window);
26
G_put_window
(&window);
27
28
/* generate DB settings file in new mapset */
29
G_asprintf
(&buffer2,
"%s/%s/VAR"
, location, mapset);
30
if
((fd = fopen(buffer2,
"w"
)) ==
NULL
) {
31
perror(
"fopen"
);
32
G_fatal_error
(
"Cannot create <%s> file in new mapset"
, buffer2);
33
}
34
fprintf(fd,
"DB_DRIVER: dbf\n"
);
35
fprintf(fd,
"DB_DATABASE: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/\n"
);
36
fclose(fd);
37
G_free
(buffer2);
38
39
/* Make the dbf/ subdirectory */
40
sprintf(buffer,
"%s/%s/dbf"
, location, mapset);
41
if
(
G_mkdir
(buffer) != 0)
42
return
-1;
43
44
return
(0);
45
}
lib
init
mke_mapset.c
Generated on Wed Jun 6 2012 14:04:26 for GRASS Programmer's Manual by
1.8.1