]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filesys.cpp
toplevel code transferred to wxTopLevelWindow
[wxWidgets.git] / src / common / filesys.cpp
index 8509d41a021bb3ccda2a40d63df1bb66a5f4b860..e83909d8477eff8b07a01997e7eddee2f158d49b 100644 (file)
 IMPLEMENT_ABSTRACT_CLASS(wxFileSystemHandler, wxObject)
 
 
+#if wxUSE_MIMETYPE
 static wxFileTypeInfo *gs_FSMimeFallbacks = NULL;
+#endif
 
 wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
 {
+#if wxUSE_MIMETYPE
     wxString ext = wxEmptyString, mime = wxEmptyString;
     wxString loc = GetRightLocation(location);
     char c;
@@ -67,6 +70,9 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
     delete ft;
 
     return mime;
+#else
+    return wxEmptyString;
+#endif
 }
 
 
@@ -138,15 +144,8 @@ wxString wxFileSystemHandler::FindNext()
 // wxLocalFSHandler
 //--------------------------------------------------------------------------------
 
-class wxLocalFSHandler : public wxFileSystemHandler
-{
-    public:
-        virtual bool CanOpen(const wxString& location);
-        virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
-        virtual wxString FindFirst(const wxString& spec, int flags = 0);
-        virtual wxString FindNext();
-};
 
+wxString wxLocalFSHandler::ms_root;
 
 bool wxLocalFSHandler::CanOpen(const wxString& location)
 {
@@ -156,23 +155,23 @@ bool wxLocalFSHandler::CanOpen(const wxString& location)
 wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
 {
     // location has Unix path separators
-    wxString right = GetRightLocation(location);
-    wxFileName fn( right, wxPATH_UNIX );
+    wxString right = ms_root + GetRightLocation(location);
+    wxFileName fn(right, wxPATH_UNIX);
     
-    if (!wxFileExists( fn.GetFullPath() ))
+    if (!wxFileExists(fn.GetFullPath()))
         return (wxFSFile*) NULL;
         
-    return new wxFSFile(new wxFileInputStream( fn.GetFullPath() ),
+    return new wxFSFile(new wxFileInputStream(fn.GetFullPath()),
                         right,
                         GetMimeTypeFromExt(location),
                         GetAnchor(location),
-                        wxDateTime(wxFileModificationTime( fn.GetFullPath() )));
+                        wxDateTime(wxFileModificationTime(fn.GetFullPath())));
 
 }
 
 wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags)
 {
-    wxString right = GetRightLocation(spec);
+    wxString right = ms_root + GetRightLocation(spec);
     return wxFindFirstFile(right, flags);
 }
 
@@ -414,6 +413,7 @@ class wxFileSystemModule : public wxModule
         {
             wxFileSystem::AddHandler(new wxLocalFSHandler);
 
+        #if wxUSE_MIMETYPE
             gs_FSMimeFallbacks = new wxFileTypeInfo[6];
             gs_FSMimeFallbacks[0] =
             wxFileTypeInfo("image/jpeg",
@@ -448,12 +448,14 @@ class wxFileSystemModule : public wxModule
             gs_FSMimeFallbacks[5] =
             // must terminate the table with this!
             wxFileTypeInfo();
-
+        #endif
             return TRUE;
         }
         virtual void OnExit()
        {
+        #if wxUSE_MIMETYPE
             delete [] gs_FSMimeFallbacks;
+        #endif
             wxFileSystem::CleanUpHandlers();
        }
 };