]> git.saurik.com Git - wxWidgets.git/blob - src/common/fs_zip.cpp
Added GSocket_Init and GSocket_Cleanup
[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 #if !wxUSE_SOCKETS
21 #undef wxUSE_FS_ZIP
22 #define wxUSE_FS_ZIP 0
23 #endif
24
25 #if wxUSE_FS_ZIP
26
27 #ifndef WXPRECOMP
28 #include <wx/wx.h>
29 #endif
30
31 #include "wx/filesys.h"
32 #include "wx/zipstream.h"
33 #include "wx/fs_zip.h"
34
35
36 //--------------------------------------------------------------------------------
37 // wxZipFSHandler
38 //--------------------------------------------------------------------------------
39
40
41
42 bool wxZipFSHandler::CanOpen(const wxString& location)
43 {
44 wxString p = GetProtocol(location);
45 return (p == "zip");
46 }
47
48
49
50
51 wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
52 {
53 wxString right = GetRightLocation(location);
54 wxString left = GetLeftLocation(location);
55 wxInputStream *s;
56
57 if (GetProtocol(left) != "file") {
58 return NULL;
59 }
60
61 s = new wxZipInputStream(left, right);
62 if (s && (s -> LastError() == wxStream_NOERROR)) {
63 return new wxFSFile(s,
64 left + "#zip:" + right,
65 GetMimeTypeFromExt(location),
66 GetAnchor(location));
67 }
68 else return NULL;
69 }
70
71
72
73 wxZipFSHandler::~wxZipFSHandler()
74 {
75 }
76
77 #endif // wxUSE_FS_ZIP