]> git.saurik.com Git - wxWidgets.git/commitdiff
check whether input stream is readable in OpenFile() (patch 808941)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Sep 2003 00:01:08 +0000 (00:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Sep 2003 00:01:08 +0000 (00:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23699 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/filesys.cpp

index 648130d0014d6a3b41b9f5d7cc5238330cede6a5..6892ca1ecf109ef5431b8005521ccd10276f88dd 100644 (file)
@@ -186,7 +186,16 @@ wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString&
     if (!wxFileExists(fullpath))
         return (wxFSFile*) NULL;
 
     if (!wxFileExists(fullpath))
         return (wxFSFile*) NULL;
 
-    return new wxFSFile(new wxFFileInputStream(fullpath),
+    // we need to check whether we can really read from this file, otherwise
+    // wxFSFile is not going to work
+    wxFFileInputStream *is = new wxFFileInputStream(fullpath);
+    if ( !is->Ok() )
+    {
+        delete is;
+        return (wxFSFile*) NULL;
+    }
+
+    return new wxFSFile(is,
                         right,
                         GetMimeTypeFromExt(location),
                         GetAnchor(location)
                         right,
                         GetMimeTypeFromExt(location),
                         GetAnchor(location)