17 #include <grass/config.h>
22 #include <sys/types.h>
25 #include <grass/gis.h>
27 static int recursive_remove(
const char *path);
28 static int G__remove(
int misc,
const char *dir,
const char *element,
49 return G__remove(0,
NULL, element, name);
69 return G__remove(1, dir, element, name);
72 static int G__remove(
int misc,
const char *dir,
const char *element,
82 if (strcmp(mapset, xmapset) != 0)
96 if (access(path, 0) != 0)
99 if (recursive_remove(path) == 0)
106 static int recursive_remove(
const char *path)
111 char path2[GPATH_MAX];
115 if (!S_ISDIR(sb.st_mode))
116 return remove(path) == 0 ? 0 : 1;
121 if (dp->d_name[0] ==
'.')
123 if (strlen(path) + strlen(dp->d_name) + 2 >
sizeof(path2))
125 sprintf(path2,
"%s/%s", path, dp->d_name);
126 recursive_remove(path2);
130 return rmdir(path) == 0 ? 0 : 1;
char * G_mapset(void)
current mapset name
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
char * G__file_name_misc(char *path, const char *dir, const char *element, const char *name, const char *mapset)
int G_lstat(const char *file_name, struct stat *buf)
Get file status.
char * G__file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
int G_remove(const char *element, const char *name)
Remove a database file.
int G_remove_misc(const char *dir, const char *element, const char *name)
Remove a database misc file.
int G_legal_filename(const char *s)
Check for legal database file name.
int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)