Browse Source

r.in.lidar: test if file exists

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57951 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 11 years ago
parent
commit
b089ec9e54
1 changed files with 5 additions and 1 deletions
  1. 5 1
      raster/r.in.lidar/main.c

+ 5 - 1
raster/r.in.lidar/main.c

@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <math.h>
 #include <sys/types.h>
 #include <grass/gis.h>
@@ -273,8 +274,11 @@ int main(int argc, char *argv[])
 	scan_flag->answer = 1; /* pointer not int, so set = shell_style->answer ? */
     }
 
+    /* Don't crash on cmd line if file not found */
+    if (access(infile, F_OK) != 0) {
+	G_fatal_error(_("Input file <%s> does not exist"), infile);
+    }
     /* Open LAS file*/
-    /* TODO: don't crash on cmd line if file not found. This test still fails */
     LAS_reader = LASReader_Create(infile);
     if (LAS_reader == NULL) {
 	G_fatal_error(_("Unable to open file <%s>"), infile);