瀏覽代碼

libgis: call fatal error when unable to read GISRC file

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67044 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 年之前
父節點
當前提交
9eec0f49b3
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      lib/gis/env.c

+ 8 - 0
lib/gis/env.c

@@ -17,6 +17,8 @@
 #include <stdlib.h>
 #include <unistd.h>		/* for sleep() */
 #include <string.h>
+#include <errno.h>
+
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
@@ -151,6 +153,9 @@ static int read_env(int loc)
         fclose(fd);
     }
 
+    if (!fd) /* reading failed, call fatal error */
+      G_fatal_error(_("Unable to read GISRC <%s>: %s"), loc, strerror(errno));
+
     G_initialize_done(&st->init[loc]);
     return 0;
 }
@@ -167,6 +172,9 @@ static void force_read_env(int loc)
         parse_env(fd, loc);
         fclose(fd);
     }
+    
+    if (!fd) /* reading failed, call fatal error */
+      G_fatal_error(_("Unable to read GISRC <%s>: %s"), loc, strerror(errno));
 }