]> git.saurik.com Git - wxWidgets.git/blob - src/common/fs_zip.cpp
2bd3b224ed2beef7727e6216d67905e1ede9d3ed
[wxWidgets.git] / src / common / fs_zip.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fs_zip.cpp
3 // Purpose: ZIP file system
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <wx/wxprec.h>
15
16 #ifdef __BORDLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef WXPRECOMP
21 #include <wx/wx.h>
22 #endif
23
24 #include "wx/filesys.h"
25 #include "wx/zipstream.h"
26 #include "wx/fs_zip.h"
27
28
29 //--------------------------------------------------------------------------------
30 // wxZipFSHandler
31 //--------------------------------------------------------------------------------
32
33
34
35 bool wxZipFSHandler::CanOpen(const wxString& location)
36 {
37 wxString p = GetProtocol(location);
38 return (p == "zip");
39 }
40
41
42
43
44 wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
45 {
46 wxString right = GetRightLocation(location);
47 wxString left = GetLeftLocation(location);
48 wxInputStream *s;
49
50 if (GetProtocol(left) != "file") {
51 return NULL;
52 }
53
54 s = new wxZipInputStream(left, right);
55 if (s && (s -> LastError() == wxStream_NOERROR)) {
56 return new wxFSFile(s,
57 left + "#zip:" + right,
58 GetMimeTypeFromExt(location),
59 GetAnchor(location));
60 }
61 else return NULL;
62 }
63
64
65
66 wxZipFSHandler::~wxZipFSHandler()
67 {
68 }
69
70
71
72
73
74
75