소스 검색

libraster: more informative messages when reading a row fails

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72030 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 7 년 전
부모
커밋
3943d10c48
1개의 변경된 파일13개의 추가작업 그리고 10개의 파일을 삭제
  1. 13 10
      lib/raster/get_row.c

+ 13 - 10
lib/raster/get_row.c

@@ -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 @@ static void read_data_fp_compressed(int fd, int row, unsigned char *data_buf,
     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 @@ static void read_data_compressed(int fd, int row, unsigned char *data_buf,
     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 */