[GRASS-SVN] r58308 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 25 12:23:59 PST 2013
Author: mmetz
Date: 2013-11-25 12:23:59 -0800 (Mon, 25 Nov 2013)
New Revision: 58308
Modified:
grass/trunk/lib/gis/key_value3.c
Log:
libgis: be more verbose when opening a file fails
Modified: grass/trunk/lib/gis/key_value3.c
===================================================================
--- grass/trunk/lib/gis/key_value3.c 2013-11-25 19:54:18 UTC (rev 58307)
+++ grass/trunk/lib/gis/key_value3.c 2013-11-25 20:23:59 UTC (rev 58308)
@@ -11,6 +11,8 @@
\author CERL
*/
+#include <errno.h>
+#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
@@ -28,13 +30,13 @@
{
FILE *fp = fopen(file, "w");
if (!fp)
- G_fatal_error(_("Unable to open output file <%s>"), file);
+ G_fatal_error(_("Unable to open output file <%s>: %s"), file, strerror(errno));
if (G_fwrite_key_value(fp, kv) != 0)
- G_fatal_error(_("Error writing file <%s>"), file);
+ G_fatal_error(_("Error writing file <%s>: %s"), file, strerror(errno));
if (fclose(fp) != 0)
- G_fatal_error(_("Error closing output file <%s>"), file);
+ G_fatal_error(_("Error closing output file <%s>: %s"), file, strerror(errno));
}
/*!
@@ -55,14 +57,14 @@
fp = fopen(file, "r");
if (!fp)
- G_fatal_error(_("Unable to open input file <%s>"), file);
+ G_fatal_error(_("Unable to open input file <%s>: %s"), file, strerror(errno));
kv = G_fread_key_value(fp);
if (!kv)
- G_fatal_error(_("Error reading file <%s>"), file);
+ G_fatal_error(_("Error reading file <%s>: %s"), file, strerror(errno));
if (fclose(fp) != 0)
- G_fatal_error(_("Error closing input file <%s>"), file);
+ G_fatal_error(_("Error closing input file <%s>: %s"), file, strerror(errno));
return kv;
}
More information about the grass-commit
mailing list