]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filesys.cpp
Integrated recent API-change
[wxWidgets.git] / src / common / filesys.cpp
index 96ae68773e5dd27969b300244aa3917bee66cf8e..d5a3bf6454a1b16cd49a1ae918a5034e632762c8 100644 (file)
     #define wxUSE_FS_INET 0
 #endif
 
-#if (wxUSE_FS_INET || wxUSE_FS_ZIP) && wxUSE_STREAMS
+#if (wxUSE_HTML || wxUSE_FS_INET || wxUSE_FS_ZIP) && wxUSE_STREAMS
 
 #include "wx/wfstream.h"
 #include "wx/module.h"
 #include "wx/filesys.h"
+#include "wx/mimetype.h"
+
+
+
 
 //--------------------------------------------------------------------------------
 // wxFileSystemHandler
 
 IMPLEMENT_ABSTRACT_CLASS(wxFileSystemHandler, wxObject)
 
-wxMimeTypesManager *wxFileSystemHandler::m_MimeMng = NULL;
-
-void wxFileSystemHandler::CleanUpStatics()
-{
-    if (m_MimeMng) delete m_MimeMng;
-    m_MimeMng = NULL;
-}
-
 
 wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
 {
@@ -58,9 +54,8 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
         if ((c == wxT('/')) || (c == wxT('\\')) || (c == wxT(':'))) {return wxEmptyString;}
     }
 
-    if (m_MimeMng == NULL) {
-        m_MimeMng = new wxMimeTypesManager;
-
+    static bool s_MinimalMimeEnsured = FALSE;
+    if (!s_MinimalMimeEnsured) {
         static const wxFileTypeInfo fallbacks[] =
         {
             wxFileTypeInfo("image/jpeg",
@@ -93,10 +88,10 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
             wxFileTypeInfo()
         };
 
-        m_MimeMng -> AddFallbacks(fallbacks);
+        wxTheMimeTypesManager -> AddFallbacks(fallbacks);
     }
 
-    ft = m_MimeMng -> GetFileTypeFromExtension(ext);
+    ft = wxTheMimeTypesManager -> GetFileTypeFromExtension(ext);
     if (ft && (ft -> GetMimeType(&mime))) {
         delete ft; 
         return mime;
@@ -161,11 +156,16 @@ wxString wxFileSystemHandler::GetAnchor(const wxString& location) const
 }
 
 
-wxString wxFileSystemHandler::FindFirst(const wxString& spec, int flags)  { return wxEmptyString; }
-
-wxString wxFileSystemHandler::FindNext() { return wxEmptyString; }
-
+wxString wxFileSystemHandler::FindFirst(const wxString& WXUNUSED(spec),
+                                        int WXUNUSED(flags))
+{
+    return wxEmptyString;
+}
 
+wxString wxFileSystemHandler::FindNext()
+{
+    return wxEmptyString;
+}
 
 //--------------------------------------------------------------------------------
 // wxLocalFSHandler
@@ -193,7 +193,8 @@ wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString&
         return new wxFSFile(new wxFileInputStream(right),
                             right,
                             GetMimeTypeFromExt(location),
-                            GetAnchor(location));
+                            GetAnchor(location),
+                            wxDateTime(wxFileModificationTime(right)));
     else return (wxFSFile*) NULL;
 }
 
@@ -307,10 +308,10 @@ wxFSFile* wxFileSystem::OpenFile(const wxString& location)
         while (node)
        {
             wxFileSystemHandler *h = (wxFileSystemHandler*) node -> GetData();
-            if (h->CanOpen(m_Path + location))
+            if (h->CanOpen(m_Path + loc))
                {
-                s = h->OpenFile(*this, m_Path + location);
-                if (s) { m_LastName = m_Path + location; break; }
+                s = h->OpenFile(*this, m_Path + loc);
+                if (s) { m_LastName = m_Path + loc; break; }
             }
             node = node->GetNext();
         }
@@ -323,10 +324,10 @@ wxFSFile* wxFileSystem::OpenFile(const wxString& location)
         while (node)
        {
             wxFileSystemHandler *h = (wxFileSystemHandler*) node->GetData();
-            if (h->CanOpen(location))
+            if (h->CanOpen(loc))
            {
-                s = h->OpenFile(*this, location);
-                if (s) { m_LastName = location; break; }
+                s = h->OpenFile(*this, loc);
+                if (s) { m_LastName = loc; break; }
             }
             node = node->GetNext();
         }
@@ -406,7 +407,6 @@ class wxFileSystemModule : public wxModule
         }
         virtual void OnExit()
        {
-           wxFileSystemHandler::CleanUpStatics();
             wxFileSystem::CleanUpHandlers();
        }
 };