-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathw_zip.h
117 lines (96 loc) · 3.1 KB
/
w_zip.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 2012 James Haley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//-----------------------------------------------------------------------------
//
// DESCRIPTION:
// ZIP Archive Loading
//
//-----------------------------------------------------------------------------
#ifndef W_ZIP_H__
#define W_ZIP_H__
#include "z_zone.h"
#include "m_dllist.h"
class InBuffer;
class WadDirectory;
struct ZIPEndOfCentralDir;
class ZipFile;
struct ZipLump
{
int gpFlags; // GP flags from zip directory entry
int flags; // internal flags
int method; // compression method
uint32_t compressed; // compressed size
uint32_t size; // uncompressed size
long offset; // file offset
char *name; // full name
ZipFile *file; // parent zipfile
void setAddress(InBuffer &fin);
void read(void *buffer);
};
struct ZipWad
{
void *buffer;
size_t size;
DLListItem<ZipWad> links;
};
class ZipFile : public ZoneObject
{
public:
// Compression methods (definition does not imply support)
enum
{
METHOD_STORED = 0,
METHOD_SHRINK = 1,
METHOD_IMPLODE = 6,
METHOD_DEFLATE = 8,
METHOD_BZIP2 = 12,
METHOD_LZMA = 14,
METHOD_PPMD = 98
};
// Lump flags
enum
{
LF_CALCOFFSET = 0x00000001, // Needs true data offset calculated
LF_ISEMBEDDEDWAD = 0x00000002 // Is an embedded WAD file
};
protected:
ZipLump *lumps; // directory
int numLumps; // directory size
FILE *file; // physical disk file
DLListItem<ZipFile> links; // links for use by WadDirectory
DLListItem<ZipWad> *wads; // wads loaded from inside the zip
bool readEndOfCentralDir(InBuffer &fin, ZIPEndOfCentralDir &zcd);
bool readCentralDirEntry(InBuffer &fin, ZipLump &lump, bool &skip);
bool readCentralDirectory(InBuffer &fin, long offset, uint32_t size);
public:
ZipFile()
: ZoneObject(), lumps(NULL), numLumps(0), file(NULL), links(), wads(NULL)
{
}
~ZipFile();
bool readFromFile(FILE *f);
void checkForWadFiles(WadDirectory &parentDir);
void linkTo(DLListItem<ZipFile> **head);
ZipLump &getLump(int lumpNum);
int getNumLumps() const { return numLumps; }
FILE *getFile() const { return file; }
};
#endif
// EOF