14 #include <grass/config.h>
19 #include <sys/types.h>
22 #include <grass/gis.h>
24 static int G__remove(
int misc,
const char *dir,
const char *
element,
69 static int G__remove(
int misc,
const char *dir,
const char *
element,
74 char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
79 if (strcmp(mapset, xmapset) != 0)
93 if (access(
path, 0) != 0)
117 char path2[GPATH_MAX];
121 if (!S_ISDIR(sb.st_mode))
122 return remove(
path) == 0 ? 0 : -1;
126 while ((dp = readdir(dirp)) !=
NULL) {
127 if (dp->d_name[0] ==
'.')
129 if (strlen(
path) + strlen(dp->d_name) + 2 >
sizeof(path2))
131 snprintf(path2,
sizeof(path2),
"%s/%s",
path, dp->d_name);
136 return rmdir(
path) == 0 ? 0 : -1;
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
char * G_file_name_misc(char *path, const char *dir, const char *element, const char *name, const char *mapset)
Builds full path names to GIS misc data files.
int G_legal_filename(const char *s)
Check for legal database file name.
const char * G_mapset(void)
Get current mapset name.
int G_name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
int G_lstat(const char *file_name, struct stat *buf)
Get file status.
int G_remove(const char *element, const char *name)
Remove a database file.
int G_recursive_remove(const char *path)
Recursively remove all files in given directory.
int G_remove_misc(const char *dir, const char *element, const char *name)
Remove a database misc file.