Author: post
Date: 2009-08-10 20:54:25 +0200 (Mon, 10 Aug 2009)
New Revision: 110

Modified:
   RawSpeed/FileIOException.cpp
   RawSpeed/FileIOException.h
   RawSpeed/FileReader.cpp
   RawSpeed/TiffParserException.h
   RawSpeed/rawstudio-plugin-api.cpp
Log:
- Don't Throw FileIOException as pointer.
- Fix bug, where FileIOException remained uncaught in RawStudio interface.
- Make FileIOException inherit from RawDecoderException.
- Minor cleanup in TiffParserException (unrelated).
- Usual stupid lineending changes.

Modified: RawSpeed/FileIOException.cpp
===================================================================
--- RawSpeed/FileIOException.cpp        2009-08-10 18:25:59 UTC (rev 109)
+++ RawSpeed/FileIOException.cpp        2009-08-10 18:54:25 UTC (rev 110)
@@ -1,31 +1,43 @@
 #include "StdAfx.h"
 #include "FileIOException.h"
-/* 
-    RawSpeed - RAW file decoder.
-
-    Copyright (C) 2009 Klaus Post
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
+#ifndef WIN32
+#include <stdarg.h>
+#define vsprintf_s(...) vsnprintf(__VA_ARGS__)
+#endif
+
+/* 
+    RawSpeed - RAW file decoder.
+
+    Copyright (C) 2009 Klaus Post
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
 
     http://www.klauspost.com
 */
 
-FileIOException::FileIOException(const string error)
+FileIOException::FileIOException(const string error) : 
RawDecoderException(error)
 {
 }
 
-FileIOException::~FileIOException(void)
-{
-}
+
+void ThrowFIE(const char* fmt, ...) {
+  va_list val;
+  va_start(val, fmt);
+  char buf[8192];
+  vsprintf_s(buf, 8192, fmt, val);
+  va_end(val);
+  _RPT1(0, "EXCEPTION: %s\n",buf);
+  throw FileIOException(buf);
+}
\ No newline at end of file

Modified: RawSpeed/FileIOException.h
===================================================================
--- RawSpeed/FileIOException.h  2009-08-10 18:25:59 UTC (rev 109)
+++ RawSpeed/FileIOException.h  2009-08-10 18:54:25 UTC (rev 110)
@@ -1,3 +1,5 @@
+#include "RawDecoderException.h"
+
 /* 
     RawSpeed - RAW file decoder.
 
@@ -15,15 +17,16 @@
 
     You should have received a copy of the GNU Lesser General Public
     License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
-
-    http://www.klauspost.com
-*/
-#pragma once
-
-class FileIOException
-{
-public:
-  FileIOException(const string);
-  virtual ~FileIOException(void);
-};
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+
+void ThrowTPE(const char* fmt, ...);
+
+class FileIOException: public RawDecoderException
+{
+public:
+  FileIOException(const string);
+};

Modified: RawSpeed/FileReader.cpp
===================================================================
--- RawSpeed/FileReader.cpp     2009-08-10 18:25:59 UTC (rev 109)
+++ RawSpeed/FileReader.cpp     2009-08-10 18:54:25 UTC (rev 110)
@@ -44,7 +44,7 @@
   stat(mFilename, &st);
   fd = open(mFilename, O_RDONLY);
   if (fd < 0)
-    throw new FileIOException("Could not open file.");
+    throw FileIOException("Could not open file.");
 #if 0
   // Not used, as it is slower than sync read
 
@@ -64,7 +64,7 @@
   HANDLE file_h;  // File handle
   file_h = CreateFile(mFilename, GENERIC_READ, FILE_SHARE_READ, NULL, 
OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN, NULL);
   if (file_h == INVALID_HANDLE_VALUE) {
-    throw new FileIOException("Could not open file.");
+    throw FileIOException("Could not open file.");
   }
 
   LARGE_INTEGER f_size;
@@ -76,7 +76,7 @@
   if (! ReadFile(file_h, fileData->getDataWrt(0), fileData->getSize(), 
&bytes_read, NULL)) {
     CloseHandle(file_h);
     delete fileData;
-    throw new FileIOException("Could not read file.");
+    throw FileIOException("Could not read file.");
   }
   CloseHandle(file_h);
 

Modified: RawSpeed/TiffParserException.h
===================================================================
--- RawSpeed/TiffParserException.h      2009-08-10 18:25:59 UTC (rev 109)
+++ RawSpeed/TiffParserException.h      2009-08-10 18:54:25 UTC (rev 110)
@@ -27,6 +27,4 @@
 {
 public:
   TiffParserException(const string _msg);
-  //~TiffParserException(void);
-//  const string msg;
 };

Modified: RawSpeed/rawstudio-plugin-api.cpp
===================================================================
--- RawSpeed/rawstudio-plugin-api.cpp   2009-08-10 18:25:59 UTC (rev 109)
+++ RawSpeed/rawstudio-plugin-api.cpp   2009-08-10 18:54:25 UTC (rev 110)
@@ -42,6 +42,7 @@
                c = new CameraMetaData(path);
                g_free(path);
        }
+
        RS_IMAGE16 *image = NULL;
        FileReader f((char *) filename);
        RawDecoder *d = 0;
@@ -53,7 +54,14 @@
                GTimer *gt = g_timer_new();
 #endif
 
-               m = f.readFile();
+               try
+               {
+                       m = f.readFile();
+               } catch (FileIOException e) {
+                       printf("RawSpeed: IO Error occured:%s\n", e.what());
+                       g_timer_destroy(gt);
+                       return image;
+               }
 
 #ifdef TIME_LOAD
                printf("Open %s: %.03fs\n", filename, g_timer_elapsed(gt, 
NULL));


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

Reply via email to