/src/ogre/OgreMain/include/OgreZip.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #ifndef __Zip_H__ |
29 | | #define __Zip_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | |
33 | | #include "OgreArchive.h" |
34 | | #include "OgreArchiveFactory.h" |
35 | | #include "OgreHeaderPrefix.h" |
36 | | #include "Threading/OgreThreadHeaders.h" |
37 | | |
38 | | struct AAssetManager; |
39 | | struct AAsset; |
40 | | |
41 | | namespace Ogre { |
42 | | |
43 | | /** \addtogroup Core |
44 | | * @{ |
45 | | */ |
46 | | /** \addtogroup Resources |
47 | | * @{ |
48 | | */ |
49 | | |
50 | | /** Specialisation to allow reading of files from a zip |
51 | | format source archive. |
52 | | |
53 | | This archive format supports all archives compressed in the standard |
54 | | zip format, including iD pk3 files. |
55 | | */ |
56 | | class _OgreExport ZipArchiveFactory : public ArchiveFactory |
57 | | { |
58 | | public: |
59 | 0 | virtual ~ZipArchiveFactory() {} |
60 | | /// @copydoc FactoryObj::getType |
61 | | const String& getType(void) const override; |
62 | | |
63 | | //! @cond Doxygen_Suppress |
64 | | using ArchiveFactory::createInstance; |
65 | | //! @endcond |
66 | | |
67 | | Archive *createInstance( const String& name, bool readOnly ) override; |
68 | | }; |
69 | | |
70 | | /** Specialisation of ZipArchiveFactory for embedded Zip files. */ |
71 | | class _OgreExport EmbeddedZipArchiveFactory : public ZipArchiveFactory |
72 | | { |
73 | | public: |
74 | | EmbeddedZipArchiveFactory(); |
75 | | virtual ~EmbeddedZipArchiveFactory(); |
76 | | |
77 | | const String& getType(void) const override; |
78 | | |
79 | | //! @cond Doxygen_Suppress |
80 | | using ArchiveFactory::createInstance; |
81 | | //! @endcond |
82 | | |
83 | | Archive *createInstance( const String& name, bool readOnly ) override; |
84 | | void destroyInstance( Archive* ptr) override; |
85 | | |
86 | | /** a function type to decrypt embedded zip file |
87 | | @param pos pos in file |
88 | | @param buf current buffer to decrypt |
89 | | @param len - length of buffer |
90 | | @return success |
91 | | */ |
92 | | typedef bool (*DecryptEmbeddedZipFileFunc)(size_t pos, void* buf, size_t len); |
93 | | |
94 | | /// Add an embedded file to the embedded file list |
95 | | static void addEmbbeddedFile(const String& name, const uint8 * fileData, |
96 | | size_t fileSize, DecryptEmbeddedZipFileFunc decryptFunc); |
97 | | |
98 | | /// Remove an embedded file to the embedded file list |
99 | | static void removeEmbbeddedFile(const String& name); |
100 | | |
101 | | }; |
102 | | |
103 | | #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID |
104 | | class APKZipArchiveFactory : public EmbeddedZipArchiveFactory |
105 | | { |
106 | | std::map<String, AAsset*> mOpenAssets; |
107 | | private: |
108 | | AAssetManager* mAssetMgr; |
109 | | public: |
110 | | APKZipArchiveFactory(AAssetManager* assetMgr) : mAssetMgr(assetMgr) {} |
111 | | virtual ~APKZipArchiveFactory() {} |
112 | | |
113 | | const String& getType(void) const override; |
114 | | Archive *createInstance( const String& name, bool readOnly ) override; |
115 | | void destroyInstance( Archive* ptr) override; |
116 | | }; |
117 | | #endif |
118 | | |
119 | | /** @} */ |
120 | | /** @} */ |
121 | | |
122 | | } |
123 | | |
124 | | #include "OgreHeaderSuffix.h" |
125 | | |
126 | | #endif |