Преглед изворни кода

print error when failing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36227 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler пре 16 година
родитељ
комит
3c374600e3
1 измењених фајлова са 9 додато и 5 уклоњено
  1. 9 5
      lib/gis/mapset_msc.c

+ 9 - 5
lib/gis/mapset_msc.c

@@ -12,6 +12,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <grass/gis.h>
@@ -54,11 +55,14 @@ int G__make_mapset_element(const char *p_element)
     while (1) {
 	if (*element == '/' || *element == 0) {
 	    *p = 0;
-	    if (access(path, 0) != 0)
-		G_mkdir(path);
-	    if (access(path, 0) != 0)
-		G_fatal_error(_("Unable to make mapset element %s (%s)"),
-			      p_element, path);
+	    if (access(path, 0) != 0) { /* directory not yet created */
+		if (G_mkdir(path) != 0)
+		    G_fatal_error(_("Unable to make mapset element %s (%s): %s"),
+				  p_element, path, strerror(errno));
+	    }
+	    if (access(path, 0) != 0)  /* directory not accessible */
+		G_fatal_error(_("Unable to make mapset element %s (%s): %s"),
+			      p_element, path, strerror(errno));
 	    if (*element == 0)
 		return 1;
 	}