]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fs_zip.cpp
Added chapter on collection and container classes to contents
[wxWidgets.git] / src / common / fs_zip.cpp
index a9939637d23e1b472ab8317ec0281f8e7b0a4216..e78ce297a0ffb5907a39631b6615f4d7ceb953e3 100644 (file)
 #pragma implementation
 #endif
 
-#include <wx/wxprec.h>
+#include "wx/wxprec.h"
 
 #ifdef __BORDLANDC__
 #pragma hdrstop
 #endif
 
-#if wxUSE_FS_ZIP
+#if wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_ZIPSTREAM
 
 #ifndef WXPRECOMP
-#include <wx/wx.h>
+#include "wx/wx.h"
 #endif
 
 #include "wx/filesys.h"
@@ -61,7 +61,7 @@ wxZipFSHandler::~wxZipFSHandler()
 bool wxZipFSHandler::CanOpen(const wxString& location)
 {
     wxString p = GetProtocol(location);
-    return (p == "zip");
+    return (p == wxT("zip") );
 }
 
 
@@ -73,18 +73,21 @@ wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& l
     wxString left = GetLeftLocation(location);
     wxInputStream *s;
 
-    if (GetProtocol(left) != "file") {
+    if (GetProtocol(left) != wxT("file")) {
         return NULL;
     }
 
     s = new wxZipInputStream(left, right);
     if (s && (s -> LastError() == wxStream_NOERROR)) {
         return new wxFSFile(s,
-                            left + "#zip:" + right,
+                            left + wxT("#zip:") + right,
                             GetMimeTypeFromExt(location),
-                            GetAnchor(location));
+                            GetAnchor(location),
+                            wxDateTime(wxFileModificationTime(left)));
     }
-    else return NULL;
+
+    delete s;
+    return NULL;
 }
 
 
@@ -101,7 +104,7 @@ wxString wxZipFSHandler::FindFirst(const wxString& spec, int flags)
         m_Archive = NULL;
     }
 
-    if (GetProtocol(left) != "file") {
+    if (GetProtocol(left) != wxT("file")) {
         return wxEmptyString;
     }
 
@@ -112,7 +115,7 @@ wxString wxZipFSHandler::FindFirst(const wxString& spec, int flags)
     }
 
     m_ZipFile = left;
-    m_Archive = (void*) unzOpen(m_ZipFile.fn_str());
+    m_Archive = (void*) unzOpen(m_ZipFile.mb_str());
     m_Pattern = right.AfterLast(wxT('/'));
     m_BaseDir = right.BeforeLast(wxT('/'));
 
@@ -146,7 +149,7 @@ wxString wxZipFSHandler::DoFind()
     while (match == wxEmptyString)
     {
         unzGetCurrentFileInfo((unzFile)m_Archive, NULL, namebuf, 1024, NULL, 0, NULL, 0);
-        for (c = namebuf; *c; c++) if (*c == '\\') *c = '/';
+        for (c = namebuf; *c; c++) if (*c == wxT('\\')) *c = wxT('/');
         fn = namebuf;
         if (fn.Last() == wxT('/')) {
             fn.RemoveLast();
@@ -176,4 +179,5 @@ wxString wxZipFSHandler::DoFind()
 
 
 
-#endif // wxUSE_FS_ZIP
+#endif 
+      //wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_ZIPSTREAM