Author: abrander
Date: 2009-08-09 23:50:24 +0200 (Sun, 09 Aug 2009)
New Revision: 106

Modified:
   RawSpeed/FileReader.cpp
Log:
- Handle empty or non-existing files in FileReader::readFile() for unix hosts.

Modified: RawSpeed/FileReader.cpp
===================================================================
--- RawSpeed/FileReader.cpp     2009-08-09 17:13:37 UTC (rev 105)
+++ RawSpeed/FileReader.cpp     2009-08-09 21:50:24 UTC (rev 106)
@@ -43,6 +43,8 @@
 
   stat(mFilename, &st);
   fd = open(mFilename, O_RDONLY);
+  if (fd < 0)
+    throw new FileIOException("Could not open file.");
 #if 0
   // Not used, as it is slower than sync read
 
@@ -52,7 +54,7 @@
 #else 
   FileMap *fileData = new FileMap(st.st_size);
 
-  while(bytes_read < st.st_size) {
+  while((st.st_size > 0) && (bytes_read < st.st_size)) {
     dest = (char *) fileData->getDataWrt(bytes_read);
     bytes_read += read(fd, dest, st.st_size-bytes_read);
   }


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to