ソースを参照

report mapset to switch to; find out who's busy there

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49748 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 13 年 前
コミット
4b40f27308
1 ファイル変更15 行追加8 行削除
  1. 15 8
      general/g.mapset/main.c

+ 15 - 8
general/g.mapset/main.c

@@ -155,16 +155,18 @@ int main(int argc, char *argv[])
     ret = G__mapset_permissions2(gisdbase_new, location_new, mapset_new);
     switch (ret) {
     case 0:
-	G_fatal_error(_("You don't have permission to use this mapset"));
+	G_fatal_error(_("You don't have permission to use the mapset <%s>"),
+	              mapset_new);
 	break;
     case -1:
 	if (flag.add->answer == TRUE) {
-	    G_debug(2, "Mapset %s doesn't exist, attempting to create it",
+	    G_debug(2, "Mapset <%s> doesn't exist, attempting to create it",
 		    mapset_new);
 	    G_make_mapset(gisdbase_new, location_new, mapset_new);
 	}
 	else
-	    G_fatal_error(_("The mapset does not exist. Use -c flag to create it."));
+	    G_fatal_error(_("Mapset <%s> does not exist. Use -c flag to create it."),
+	                  mapset_new);
 	break;
     default:
 	break;
@@ -179,17 +181,22 @@ int main(int argc, char *argv[])
 
     sprintf(path, "%s/.gislock", mapset_new_path);
     G_debug(2, path);
-
+    
     ret = G_spawn(lock_prog, lock_prog, path, gis_lock, NULL);
     G_debug(2, "lock result = %d", ret);
     G_free(lock_prog);
 
     /* Warning: the value returned by system() is not that returned by exit() in executed program
      *          e.g. exit(1) -> 256 (multiplied by 256) */
-    if (ret != 0)
-	G_fatal_error(_("<%s> is currently running GRASS in selected mapset "
-			"or lock file cannot be checked"),
-		      G_whoami());
+    if (ret != 0) {
+	/* .gislock does not exist */
+	if (access(path, F_OK) != 0)
+	    G_fatal_error(_("Lock file of mapset <%s> cannot be checked"),
+			   mapset_new);
+	else
+	    G_fatal_error(_("<%s> is currently running GRASS in selected mapset <%s>"),
+		      G_owner(path), mapset_new);
+    }
 
     /* Clean temporary directory */
     sprintf(path, "%s/etc/clean_temp", G_gisbase());