2
\file lib/manage/do_rename.c
4
\brief Manage Library - Rename elements
6
(C) 2001-2011 by the GRASS Development Team
8
This program is free software under the GNU General Public License
9
(>=v2). Read the file COPYING that comes with GRASS for details.
11
\author Original author CERL
17
#include <grass/gis.h>
18
#include <grass/vector.h>
19
#include <grass/raster3d.h>
20
#include <grass/glocale.h>
22
#include "manage_local_proto.h"
28
\param old source name
29
\param new destination name
34
int M_do_rename(int n, const char *old, const char *new)
42
G_message(_("Rename %s <%s> to <%s>"),
43
list[n].maindesc, old, new);
45
if (G_strcasecmp(old, new) == 0)
48
len = M__get_description_len(n);
52
if (G_strcasecmp(list[n].alias, "vector") == 0) {
53
if ((mapset = G_find_vector2(old, "")) == NULL) {
54
G_warning(_("Vector map <%s> not found"), old);
57
ret = Vect_rename(old, new);
62
G_warning(_("Unable to rename vector map <%s> to <%s>"),
69
if (G_strcasecmp(list[n].alias, "raster") == 0) {
70
if ((mapset = G_find_raster2(old, "")) == NULL)
71
G_warning(_("Raster map <%s> not found"), old);
74
if (G_strcasecmp(list[n].alias, "raster_3d") == 0) {
75
if ((mapset = G_find_raster3d(old, "")) == NULL)
76
G_warning(_("3D raster map <%s> not found"), old);
79
for (i = 0; i < list[n].nelem; i++) {
80
G_remove(list[n].element[i], new);
81
switch (G_rename(list[n].element[i], old, new)) {
83
G_warning(_("Unable to rename %s"), list[n].desc[i]);
87
G_verbose_message(_("%s is missing"), list[n].desc[i]);
90
G_verbose_message(_("%s renamed"), list[n].desc[i]);
96
if (G_strcasecmp(list[n].element[0], "cell") == 0) {
99
sprintf(colr2, "colr2/%s", G_mapset());
100
G_remove(colr2, new);
101
switch (G_rename(colr2, old, new)) {
103
G_warning(_("Unable to rename %s"), colr2);
107
G_verbose_message(_("%s is missing"), colr2);
110
G_verbose_message(_("%s renamed"), colr2);
119
G_warning(_("<%s> nothing renamed"), old);