]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filesys.cpp
Applied memory allocation patch, and worked around bug that crashes memcheck.cpp
[wxWidgets.git] / src / common / filesys.cpp
index ea9f9079823e42a5772d59d2d9240c3d62beb06c..85a55e95b890c687ca4d2a7c9ef90ee9138dc1e8 100644 (file)
@@ -89,14 +89,13 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
     }
 
     ft = wxTheMimeTypesManager -> GetFileTypeFromExtension(ext);
-    if (ft && (ft -> GetMimeType(&mime))) {
-        delete ft; 
-        return mime;
-    }
-    else {
-        delete ft;
-        return wxEmptyString;
+    if ( !ft || !ft -> GetMimeType(&mime) ) {
+        mime = wxEmptyString;
     }
+
+    delete ft;
+
+    return mime;
 }
 
 
@@ -186,13 +185,15 @@ bool wxLocalFSHandler::CanOpen(const wxString& location)
 wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
 {
     wxString right = GetRightLocation(location);
-    if (wxFileExists(right))
-        return new wxFSFile(new wxFileInputStream(right),
-                            right,
-                            GetMimeTypeFromExt(location),
-                            GetAnchor(location),
-                            wxDateTime(wxFileModificationTime(right)));
-    else return (wxFSFile*) NULL;
+    if (!wxFileExists(right))
+        return (wxFSFile*) NULL;
+
+    return new wxFSFile(new wxFileInputStream(right),
+                        right,
+                        GetMimeTypeFromExt(location),
+                        GetAnchor(location),
+                        wxDateTime(wxFileModificationTime(right)));
+
 }
 
 wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags)
@@ -326,11 +327,13 @@ wxFSFile* wxFileSystem::OpenFile(const wxString& location)
     meta = 0;
     for (i = 0; i < ln; i++)
     {
-        if (!meta) 
-            switch (loc[i])
-               {
-                case wxT('/') : case wxT(':') : case wxT('#') : meta = loc[i];
-            }
+        switch (loc[i])
+        {
+            case wxT('/') : case wxT(':') : case wxT('#') : 
+                meta = loc[i];
+                break;
+        }
+        if (meta != 0) break;
     }
     m_LastName = wxEmptyString;