[GRASS-SVN] r59086 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 18 07:32:06 PST 2014


Author: martinl
Date: 2014-02-18 07:32:06 -0800 (Tue, 18 Feb 2014)
New Revision: 59086

Modified:
   grass/trunk/lib/gis/make_mapset.c
Log:
G_make_mapset(): print clear error message when location doesn't exist

Modified: grass/trunk/lib/gis/make_mapset.c
===================================================================
--- grass/trunk/lib/gis/make_mapset.c	2014-02-18 14:39:58 UTC (rev 59085)
+++ grass/trunk/lib/gis/make_mapset.c	2014-02-18 15:32:06 UTC (rev 59086)
@@ -26,6 +26,8 @@
  * This function creates a new mapset in the given location,
  * initializes default window and the current window.
  *
+ * Calls G_fatal_error() if location doesn't exist.
+ *
  * \param gisdbase_name full path of GISDBASE to create mapset in
  *                      (NULL for the current GISDBASE)
  * \param location_name name of location to create mapset in
@@ -58,7 +60,12 @@
     if (G_legal_filename(mapset_name) != 1)
         return -2;
     
-    /* Make the mapset. */
+    /* Check if location exists */
+    sprintf(path, "%s/%s", gisdbase_name, location_name);
+    if (access(path, F_OK ) == -1)
+        G_fatal_error(_("Location <%s> doesn't exist"), location_name);
+    
+    /* Make the mapset */
     sprintf(path, "%s/%s/%s", gisdbase_name, location_name, mapset_name);
     if (G_mkdir(path) != 0) {
         perror("G_make_mapset");



More information about the grass-commit mailing list