00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <stdio.h>
00016 #include <string.h>
00017 #include <unistd.h>
00018 #include <stdlib.h>
00019 #include "gis.h"
00020
00021
00037 int G_remove ( char *element, char *name)
00038 {
00039 char path[1040];
00040 char *mapset;
00041 char xname[512], xmapset[512];
00042 char cmd[1100];
00043
00044 if (G_legal_filename(name) < 0)
00045 return -1;
00046
00047
00048 mapset = G_mapset();
00049 if (G__name_is_fully_qualified (name, xname, xmapset)
00050 && strcmp (mapset, xmapset))
00051 return -1;
00052
00053
00054 if (access (G__file_name (path, element, name, mapset),0) != 0)
00055 return 0;
00056
00057 if ( remove ( path ) == 0)
00058 return 1;
00059 if (strchr(path, '\''))
00060 return -1;
00061
00062 sprintf(cmd, "rm -rf '%s'", path);
00063
00064 if (G_system(cmd) == 0)
00065 return 1;
00066
00067 return -1;
00068 }
00069