00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include <string.h>
00019 #include <unistd.h>
00020 #include <grass/gis.h>
00021
00022
00039 int G_rename ( char *element,
00040 char *oldname, char *newname)
00041 {
00042 char *mapset;
00043 char xname[512], xmapset[512];
00044 char from[512], to[512];
00045
00046
00047 mapset = G_mapset();
00048 if (G__name_is_fully_qualified (oldname, xname, xmapset)
00049 && strcmp (mapset, xmapset))
00050 return -1;
00051 if (G__name_is_fully_qualified (newname, xname, xmapset)
00052 && strcmp (mapset, xmapset))
00053 return -1;
00054
00055
00056 if (access (G__file_name (from, element, oldname, mapset),0) != 0)
00057 return 0;
00058
00059 G__file_name (to, element, newname, mapset);
00060
00061
00062 return rename(from, to) == 0 ? 1 : -1;
00063 }