Recognize FileNotFound on win32
authorMikko Rasa <tdb@tdb.fi>
Mon, 23 Jun 2008 20:52:17 +0000 (20:52 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 23 Jun 2008 20:52:17 +0000 (20:52 +0000)
source/file.cpp

index ac514121dfa05fe99afa9aee4e51ba9fe66361c1..6ef338888b24b610b0d61f7bcaa06d9fec2594fa 100644 (file)
@@ -57,7 +57,13 @@ File::File(const string &fn, Mode m, CreateMode cm)
 
        handle=CreateFile(fn.c_str(), flags, 0, 0, create_flags, FILE_ATTRIBUTE_NORMAL, 0);
        if(handle==INVALID_HANDLE_VALUE)
-               throw SystemError(format("Can't open file '%s'", fn), GetLastError());
+       {
+               int err=GetLastError();
+               if(err==ERROR_FILE_NOT_FOUND)
+                       throw FileNotFound("Can't find file "+fn, fn);
+               else
+                       throw SystemError(format("Can't open file '%s'", fn), GetLastError());
+       }
 #else
        int flags=0;
        switch(mode&M_RDWR)