14#include <grass/config.h>
24static int G__remove(
int misc,
const char *dir,
const char *
element,
70static int G__remove(
int misc,
const char *dir,
const char *
element,
75 char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
80 if (strcmp(mapset, xmapset) != 0)
94 if (access(
path, 0) != 0)
118 char path2[GPATH_MAX];
122 if (!S_ISDIR(sb.st_mode))
123 return remove(
path) == 0 ? 0 : -1;
127 while ((dp = readdir(dirp)) !=
NULL) {
128 if (dp->d_name[0] ==
'.')
130 if (strlen(
path) + strlen(dp->d_name) + 2 >
sizeof(path2))
132 sprintf(path2,
"%s/%s",
path, dp->d_name);
137 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.