-
Notifications
You must be signed in to change notification settings - Fork 0
/
CFileArchive.h
executable file
·114 lines (84 loc) · 3.27 KB
/
CFileArchive.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
/*
CFileArchive.h
Author: Tom Naughton
Description: <describe the CFileArchive class here>
*/
#ifndef CFileArchive_H
#define CFileArchive_H
#include <set>
#include <map>
#include <list>
#include <string>
#include <iostream.h>
#include "utilities.h"
using std::map;
using std::pair;
using std::set;
using std::list;
using std::string;
class CPakStream;
class CResourceDocument;
class CFileArchive
{
public:
// Get a list of shader script files
CFileArchive(CFileArchive *inParent);
CFileArchive(FSSpec inFileSpec);
virtual ~CFileArchive();
virtual Boolean init();
virtual void addPackageWithName(CFileArchive *package, const char *name);
virtual void addFileWithName(long index, const char *name);
CFileArchive *packageWithName(const char *entryName, Boolean create);
CPakStream *itemWithName(const char *itemName);
CPakStream *itemWithPathName(const char *itemName, Boolean searchAll = true);
long indexOfItemWithName(const char *itemName);
static CPakStream *itemWithPathNameSearchAll(const char *itemName);
CFileArchive *rootArchive();
void appendPathNamesOfTypeSearchAll(StringList *result, const char *path, const char *extension);
void appendPathNamesOfType(StringList *result, const char *path, const char *extension);
string name() { return _name; }
void setName(const char *n) { _name = n; }
void setParent(CFileArchive *p) { _parent = p; }
string pathName();
long size(const char *itemName, long inIndex);
virtual CFileArchive *subPackage(const char *name);
virtual long SizeOfItemAtIndex(const char *itemName, UInt32 inIndex); // pure virtual?
virtual void ConsoleDump(int indent);
virtual void ConsoleDumpFiles(int indent);
// called only on the root package
virtual CPakStream *LoadItemAtIndex(CFileArchive *inParent, const char *itemName, UInt32 inIndex); // pure virtual?
void setDocument(CResourceDocument *inDoc) { _document = inDoc; }
CResourceDocument *document() { return _document; }
void registerArchive();
FSSpec fsspec() { return _fileSpec; };
virtual Boolean UsesFileSpec(const FSSpec& inFileSpec) const;
// This is the C++ Standard Template Library's answer to NSDictionary
// (sick but functional)
typedef pair<string, CFileArchive*> pair_type;
typedef map<string, CFileArchive*> database_type;
typedef database_type::value_type entry_type;
typedef database_type::iterator iterator;
typedef pair<string, long> file_pair_type;
typedef map<string, long> file_database_type;
typedef file_database_type::value_type file_entry_type;
typedef file_database_type::iterator file_iterator;
virtual database_type *getSubpackages();
virtual file_database_type *getFiles();
protected:
FSSpec _fileSpec;
LFileStream *_fileStream;
private:
database_type _subpackages; // holds the subpackages
file_database_type _filesmap; // holds files in this package
CPakStream *localItemWithPathName(const char *itemName);
CResourceDocument *_document;
CFileArchive *_parent; // nil for root package
string _name;
// only valid for root
string _filename;
long _cachedSize;
typedef set<CFileArchive*> archiveset;
typedef archiveset::iterator archiveset_iterator;
static archiveset _archiveSet;
};
#endif // CFileArchive_H