[GRASS-SVN] r72030 - grass/trunk/lib/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 5 12:33:55 PST 2018


Author: mmetz
Date: 2018-01-05 12:33:55 -0800 (Fri, 05 Jan 2018)
New Revision: 72030

Modified:
   grass/trunk/lib/raster/get_row.c
Log:
libraster: more informative messages when reading a row fails

Modified: grass/trunk/lib/raster/get_row.c
===================================================================
--- grass/trunk/lib/raster/get_row.c	2018-01-04 23:05:09 UTC (rev 72029)
+++ grass/trunk/lib/raster/get_row.c	2018-01-05 20:33:55 UTC (rev 72030)
@@ -14,6 +14,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <errno.h>
 
 #include <grass/config.h>
 #include <grass/raster.h>
@@ -88,17 +89,19 @@
     off_t t2 = fcb->row_ptr[row + 1];
     size_t readamount = t2 - t1;
     size_t bufsize = fcb->cellhd.cols * fcb->nbytes;
+    int ret;
 
     if (lseek(fcb->data_fd, t1, SEEK_SET) < 0)
-	G_fatal_error(_("Error reading raster data for row %d of <%s>"),
-		      row, fcb->name);
+	G_fatal_error(_("Error seeking fp raster data file for row %d of <%s>: %s"),
+		      row, fcb->name, strerror(errno));
 
     *nbytes = fcb->nbytes;
 
-    if ((size_t) G_read_compressed(fcb->data_fd, readamount, data_buf,
-                                   bufsize, fcb->cellhd.compressed) != bufsize)
-	G_fatal_error(_("Error uncompressing raster data for row %d of <%s>"),
-		      row, fcb->name);
+    ret = G_read_compressed(fcb->data_fd, readamount, data_buf,
+			    bufsize, fcb->cellhd.compressed);
+    if (ret <= 0)
+	G_fatal_error(_("Error uncompressing fp raster data for row %d of <%s>: error code %d"),
+		      row, fcb->name, ret);
 }
 
 static void rle_decompress(unsigned char *dst, const unsigned char *src,
@@ -132,15 +135,15 @@
     int n;
 
     if (lseek(fcb->data_fd, t1, SEEK_SET) < 0)
-	G_fatal_error(_("Error reading raster data for row %d of <%s>"),
-		      row, fcb->name);
+	G_fatal_error(_("Error seeking raster data file for row %d of <%s>: %s"),
+		      row, fcb->name, strerror(errno));
 
     cmp = G_malloc(readamount);
 
     if (read(fcb->data_fd, cmp, readamount) != readamount) {
 	G_free(cmp);
-	G_fatal_error(_("Error reading raster data for row %d of <%s>"),
-		      row, fcb->name);
+	G_fatal_error(_("Error reading raster data for row %d of <%s>: %s"),
+		      row, fcb->name, strerror(errno));
     }
 
     /* save cmp for free below */



More information about the grass-commit mailing list