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