aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-03-28 22:28:34 +1000
committerDavid Walter Seikel2016-03-28 22:28:34 +1000
commit7028cbe09c688437910a25623098762bf0fa592d (patch)
tree10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h
parentMove lemon to the src/others directory. (diff)
downloadSledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h227
1 files changed, 227 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h
new file mode 100644
index 0000000..14251e8
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CZipReader.h
@@ -0,0 +1,227 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_ZIP_READER_H_INCLUDED__
6#define __C_ZIP_READER_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9
10#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
11
12#include "IReadFile.h"
13#include "irrArray.h"
14#include "irrString.h"
15#include "IFileSystem.h"
16#include "CFileList.h"
17
18namespace irr
19{
20namespace io
21{
22 // set if the file is encrypted
23 const s16 ZIP_FILE_ENCRYPTED = 0x0001;
24 // the fields crc-32, compressed size and uncompressed size are set to
25 // zero in the local header
26 const s16 ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008;
27
28// byte-align structures
29#include "irrpack.h"
30
31 struct SZIPFileDataDescriptor
32 {
33 u32 CRC32;
34 u32 CompressedSize;
35 u32 UncompressedSize;
36 } PACK_STRUCT;
37
38 struct SZIPFileHeader
39 {
40 u32 Sig; // 'PK0304' little endian (0x04034b50)
41 s16 VersionToExtract;
42 s16 GeneralBitFlag;
43 s16 CompressionMethod;
44 s16 LastModFileTime;
45 s16 LastModFileDate;
46 SZIPFileDataDescriptor DataDescriptor;
47 s16 FilenameLength;
48 s16 ExtraFieldLength;
49 // filename (variable size)
50 // extra field (variable size )
51 } PACK_STRUCT;
52
53 struct SZIPFileCentralDirFileHeader
54 {
55 u32 Sig; // 'PK0102' (0x02014b50)
56 u16 VersionMadeBy;
57 u16 VersionToExtract;
58 u16 GeneralBitFlag;
59 u16 CompressionMethod;
60 u16 LastModFileTime;
61 u16 LastModFileDate;
62 u32 CRC32;
63 u32 CompressedSize;
64 u32 UncompressedSize;
65 u16 FilenameLength;
66 u16 ExtraFieldLength;
67 u16 FileCommentLength;
68 u16 DiskNumberStart;
69 u16 InternalFileAttributes;
70 u32 ExternalFileAttributes;
71 u32 RelativeOffsetOfLocalHeader;
72
73 // filename (variable size)
74 // extra field (variable size)
75 // file comment (variable size)
76
77 } PACK_STRUCT;
78
79 struct SZIPFileCentralDirEnd
80 {
81 u32 Sig; // 'PK0506' end_of central dir signature // (0x06054b50)
82 u16 NumberDisk; // number of this disk
83 u16 NumberStart; // number of the disk with the start of the central directory
84 u16 TotalDisk; // total number of entries in the central dir on this disk
85 u16 TotalEntries; // total number of entries in the central dir
86 u32 Size; // size of the central directory
87 u32 Offset; // offset of start of centraldirectory with respect to the starting disk number
88 u16 CommentLength; // zipfile comment length
89 // zipfile comment (variable size)
90 } PACK_STRUCT;
91
92 struct SZipFileExtraHeader
93 {
94 s16 ID;
95 s16 Size;
96 } PACK_STRUCT;
97
98 struct SZipFileAESExtraData
99 {
100 s16 Version;
101 u8 Vendor[2];
102 u8 EncryptionStrength;
103 s16 CompressionMode;
104 } PACK_STRUCT;
105
106 enum E_GZIP_FLAGS
107 {
108 EGZF_TEXT_DAT = 1,
109 EGZF_CRC16 = 2,
110 EGZF_EXTRA_FIELDS = 4,
111 EGZF_FILE_NAME = 8,
112 EGZF_COMMENT = 16
113 };
114
115 struct SGZIPMemberHeader
116 {
117 u16 sig; // 0x8b1f
118 u8 compressionMethod; // 8 = deflate
119 u8 flags;
120 u32 time;
121 u8 extraFlags; // slow compress = 2, fast compress = 4
122 u8 operatingSystem;
123 } PACK_STRUCT;
124
125// Default alignment
126#include "irrunpack.h"
127
128 //! Contains extended info about zip files in the archive
129 struct SZipFileEntry
130 {
131 //! Position of data in the archive file
132 s32 Offset;
133
134 //! The header for this file containing compression info etc
135 SZIPFileHeader header;
136 };
137
138 //! Archiveloader capable of loading ZIP Archives
139 class CArchiveLoaderZIP : public IArchiveLoader
140 {
141 public:
142
143 //! Constructor
144 CArchiveLoaderZIP(io::IFileSystem* fs);
145
146 //! returns true if the file maybe is able to be loaded by this class
147 //! based on the file extension (e.g. ".zip")
148 virtual bool isALoadableFileFormat(const io::path& filename) const;
149
150 //! Check if the file might be loaded by this class
151 /** Check might look into the file.
152 \param file File handle to check.
153 \return True if file seems to be loadable. */
154 virtual bool isALoadableFileFormat(io::IReadFile* file) const;
155
156 //! Check to see if the loader can create archives of this type.
157 /** Check based on the archive type.
158 \param fileType The archive type to check.
159 \return True if the archile loader supports this type, false if not */
160 virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const;
161
162 //! Creates an archive from the filename
163 /** \param file File handle to check.
164 \return Pointer to newly created archive, or 0 upon error. */
165 virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const;
166
167 //! creates/loads an archive from the file.
168 //! \return Pointer to the created archive. Returns 0 if loading failed.
169 virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const;
170
171 private:
172 io::IFileSystem* FileSystem;
173 };
174
175/*!
176 Zip file Reader written April 2002 by N.Gebhardt.
177*/
178 class CZipReader : public virtual IFileArchive, virtual CFileList
179 {
180 public:
181
182 //! constructor
183 CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths, bool isGZip=false);
184
185 //! destructor
186 virtual ~CZipReader();
187
188 //! opens a file by file name
189 virtual IReadFile* createAndOpenFile(const io::path& filename);
190
191 //! opens a file by index
192 virtual IReadFile* createAndOpenFile(u32 index);
193
194 //! returns the list of files
195 virtual const IFileList* getFileList() const;
196
197 //! get the archive type
198 virtual E_FILE_ARCHIVE_TYPE getType() const;
199
200 protected:
201
202 //! reads the next file header from a ZIP file, returns false if there are no more headers.
203 /* if ignoreGPBits is set, the item will be read despite missing
204 file information. This is used when reading items from the central
205 directory. */
206 bool scanZipHeader(bool ignoreGPBits=false);
207
208 //! the same but for gzip files
209 bool scanGZipHeader();
210
211 bool scanCentralDirectoryHeader();
212
213 IReadFile* File;
214
215 // holds extended info about files
216 core::array<SZipFileEntry> FileInfo;
217
218 bool IsGZip;
219 };
220
221
222} // end namespace io
223} // end namespace irr
224
225#endif // __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
226#endif // __C_ZIP_READER_H_INCLUDED__
227