Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* |
---|---|
2 | Open Asset Import Library (assimp) |
3 | ---------------------------------------------------------------------- |
4 | |
5 | Copyright (c) 2006-2017, assimp team |
6 | |
7 | All rights reserved. |
8 | |
9 | Redistribution and use of this software in source and binary forms, |
10 | with or without modification, are permitted provided that the |
11 | following conditions are met: |
12 | |
13 | * Redistributions of source code must retain the above |
14 | copyright notice, this list of conditions and the |
15 | following disclaimer. |
16 | |
17 | * Redistributions in binary form must reproduce the above |
18 | copyright notice, this list of conditions and the |
19 | following disclaimer in the documentation and/or other |
20 | materials provided with the distribution. |
21 | |
22 | * Neither the name of the assimp team, nor the names of its |
23 | contributors may be used to endorse or promote products |
24 | derived from this software without specific prior |
25 | written permission of the assimp team. |
26 | |
27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | |
39 | ---------------------------------------------------------------------- |
40 | */ |
41 | #ifndef AI_Q3BSP_ZIPARCHIVE_H_INC |
42 | #define AI_Q3BSP_ZIPARCHIVE_H_INC |
43 | |
44 | #include <contrib/unzip/unzip.h> |
45 | #include <assimp/IOStream.hpp> |
46 | #include <assimp/IOSystem.hpp> |
47 | #include <vector> |
48 | #include <map> |
49 | #include <cassert> |
50 | |
51 | namespace Assimp { |
52 | namespace Q3BSP { |
53 | |
54 | // ------------------------------------------------------------------------------------------------ |
55 | /// \class IOSystem2Unzip |
56 | /// \ingroup Assimp::Q3BSP |
57 | /// |
58 | /// \brief |
59 | // ------------------------------------------------------------------------------------------------ |
60 | class IOSystem2Unzip { |
61 | public: |
62 | static voidpf open(voidpf opaque, const char* filename, int mode); |
63 | static uLong read(voidpf opaque, voidpf stream, void* buf, uLong size); |
64 | static uLong write(voidpf opaque, voidpf stream, const void* buf, uLong size); |
65 | static long tell(voidpf opaque, voidpf stream); |
66 | static long seek(voidpf opaque, voidpf stream, uLong offset, int origin); |
67 | static int close(voidpf opaque, voidpf stream); |
68 | static int testerror(voidpf opaque, voidpf stream); |
69 | static zlib_filefunc_def get(IOSystem* pIOHandler); |
70 | }; |
71 | |
72 | // ------------------------------------------------------------------------------------------------ |
73 | /// \class ZipFile |
74 | /// \ingroup Assimp::Q3BSP |
75 | /// |
76 | /// \brief |
77 | // ------------------------------------------------------------------------------------------------ |
78 | class ZipFile : public IOStream { |
79 | friend class Q3BSPZipArchive; |
80 | |
81 | public: |
82 | explicit ZipFile(size_t size); |
83 | ~ZipFile(); |
84 | size_t Read(void* pvBuffer, size_t pSize, size_t pCount ); |
85 | size_t Write(const void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/); |
86 | size_t FileSize() const; |
87 | aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/); |
88 | size_t Tell() const; |
89 | void Flush(); |
90 | |
91 | private: |
92 | void* m_Buffer; |
93 | size_t m_Size; |
94 | }; |
95 | |
96 | // ------------------------------------------------------------------------------------------------ |
97 | /// \class Q3BSPZipArchive |
98 | /// \ingroup Assimp::Q3BSP |
99 | /// |
100 | /// \brief IMplements a zip archive like the WinZip archives. Will be also used to import data |
101 | /// from a P3K archive ( Quake level format ). |
102 | // ------------------------------------------------------------------------------------------------ |
103 | class Q3BSPZipArchive : public Assimp::IOSystem { |
104 | public: |
105 | static const unsigned int FileNameSize = 256; |
106 | |
107 | public: |
108 | Q3BSPZipArchive(IOSystem* pIOHandler, const std::string & rFile); |
109 | ~Q3BSPZipArchive(); |
110 | bool Exists(const char* pFile) const; |
111 | char getOsSeparator() const; |
112 | IOStream* Open(const char* pFile, const char* pMode = "rb"); |
113 | void Close(IOStream* pFile); |
114 | bool isOpen() const; |
115 | void getFileList(std::vector<std::string> &rFileList); |
116 | |
117 | private: |
118 | bool mapArchive(); |
119 | |
120 | private: |
121 | unzFile m_ZipFileHandle; |
122 | std::map<std::string, ZipFile*> m_ArchiveMap; |
123 | }; |
124 | |
125 | // ------------------------------------------------------------------------------------------------ |
126 | |
127 | } // Namespace Q3BSP |
128 | } // Namespace Assimp |
129 | |
130 | #endif // AI_Q3BSP_ZIPARCHIVE_H_INC |
131 |
Warning: That file was not part of the compilation database. It may have many parsing errors.