18 #include "pandabase.h" 20 #include "config_express.h" 21 #include "streamWrapper.h" 22 #include "subStream.h" 24 #include "ordered_vector.h" 25 #include "indirectLess.h" 26 #include "referenceCount.h" 28 #include "openSSLWrapper.h" 44 BLOCKING
bool open_read(
const Filename &multifile_name,
const streampos &offset = 0);
45 BLOCKING
bool open_read(
IStreamWrapper *multifile_stream,
bool owns_pointer =
false,
const streampos &offset = 0);
46 BLOCKING
bool open_write(
const Filename &multifile_name);
47 BLOCKING
bool open_write(ostream *multifile_stream,
bool owns_pointer =
false);
48 BLOCKING
bool open_read_write(
const Filename &multifile_name);
49 BLOCKING
bool open_read_write(iostream *multifile_stream,
bool owns_pointer =
false);
50 BLOCKING
void close();
52 INLINE
const Filename &get_multifile_name()
const;
53 INLINE
void set_multifile_name(
const Filename &multifile_name);
55 INLINE
bool is_read_valid()
const;
56 INLINE
bool is_write_valid()
const;
57 INLINE
bool needs_repack()
const;
59 INLINE time_t get_timestamp()
const;
61 INLINE
void set_record_timestamp(
bool record_timestamp);
62 INLINE
bool get_record_timestamp()
const;
64 void set_scale_factor(
size_t scale_factor);
65 INLINE
size_t get_scale_factor()
const;
67 INLINE
void set_encryption_flag(
bool flag);
68 INLINE
bool get_encryption_flag()
const;
69 INLINE
void set_encryption_password(
const string &encryption_password);
70 INLINE
const string &get_encryption_password()
const;
72 INLINE
void set_encryption_algorithm(
const string &encryption_algorithm);
73 INLINE
const string &get_encryption_algorithm()
const;
74 INLINE
void set_encryption_key_length(
int encryption_key_length);
75 INLINE
int get_encryption_key_length()
const;
76 INLINE
void set_encryption_iteration_count(
int encryption_iteration_count);
77 INLINE
int get_encryption_iteration_count()
const;
79 string add_subfile(
const string &subfile_name,
const Filename &filename,
80 int compression_level);
81 string add_subfile(
const string &subfile_name, istream *subfile_data,
82 int compression_level);
83 string update_subfile(
const string &subfile_name,
const Filename &filename,
84 int compression_level);
87 bool add_signature(
const Filename &certificate,
90 const string &password =
"");
91 bool add_signature(
const Filename &composite,
92 const string &password =
"");
94 int get_num_signatures()
const;
95 string get_signature_subject_name(
int n)
const;
96 string get_signature_friendly_name(
int n)
const;
97 string get_signature_public_key(
int n)
const;
98 void print_signature_certificate(
int n, ostream &out)
const;
99 void write_signature_certificate(
int n, ostream &out)
const;
101 int validate_signature_certificate(
int n)
const;
102 #endif // HAVE_OPENSSL 104 BLOCKING
bool flush();
105 BLOCKING
bool repack();
107 int get_num_subfiles()
const;
108 int find_subfile(
const string &subfile_name)
const;
109 bool has_directory(
const string &subfile_name)
const;
110 bool scan_directory(vector_string &contents,
111 const string &subfile_name)
const;
112 void remove_subfile(
int index);
113 INLINE
bool remove_subfile(
const string &subfile_name);
114 const string &get_subfile_name(
int index)
const;
115 MAKE_SEQ(get_subfile_names, get_num_subfiles, get_subfile_name);
116 size_t get_subfile_length(
int index)
const;
117 time_t get_subfile_timestamp(
int index)
const;
118 bool is_subfile_compressed(
int index)
const;
119 bool is_subfile_encrypted(
int index)
const;
120 bool is_subfile_text(
int index)
const;
122 streampos get_index_end()
const;
123 streampos get_subfile_internal_start(
int index)
const;
124 size_t get_subfile_internal_length(
int index)
const;
126 BLOCKING INLINE
string read_subfile(
int index);
127 BLOCKING istream *open_read_subfile(
int index);
128 BLOCKING
static void close_read_subfile(istream *stream);
129 BLOCKING
bool extract_subfile(
int index,
const Filename &filename);
130 BLOCKING
bool extract_subfile_to(
int index, ostream &out);
131 BLOCKING
bool compare_subfile(
int index,
const Filename &filename);
133 void output(ostream &out)
const;
134 void ls(ostream &out = cout)
const;
136 static INLINE
string get_magic_number();
138 void set_header_prefix(
const string &header_prefix);
139 INLINE
const string &get_header_prefix()
const;
145 INLINE CertRecord(X509 *cert);
146 INLINE CertRecord(
const CertRecord ©);
147 INLINE ~CertRecord();
148 INLINE
void operator = (
const CertRecord &other);
153 bool add_signature(X509 *certificate, STACK_OF(X509) *chain, EVP_PKEY *pkey);
154 bool add_signature(
const CertChain &chain, EVP_PKEY *pkey);
156 const CertChain &get_signature(
int n)
const;
157 #endif // HAVE_OPENSSL 159 bool read_subfile(
int index,
string &result);
165 SF_index_invalid = 0x0002,
166 SF_data_invalid = 0x0004,
167 SF_compressed = 0x0008,
168 SF_encrypted = 0x0010,
169 SF_signature = 0x0020,
176 INLINE
bool operator < (
const Subfile &other)
const;
177 streampos read_index(istream &read, streampos fpos,
179 streampos write_index(ostream &write, streampos fpos,
181 streampos write_data(ostream &write, istream *read, streampos fpos,
183 void rewrite_index_data_start(ostream &write,
Multifile *multifile);
184 void rewrite_index_flags(ostream &write);
185 INLINE
bool is_deleted()
const;
186 INLINE
bool is_index_invalid()
const;
187 INLINE
bool is_data_invalid()
const;
188 INLINE
bool is_cert_special()
const;
189 INLINE streampos get_last_byte_pos()
const;
192 streampos _index_start;
193 size_t _index_length;
194 streampos _data_start;
196 size_t _uncompressed_length;
201 int _compression_level;
207 INLINE streampos word_to_streampos(
size_t word)
const;
208 INLINE
size_t streampos_to_word(streampos fpos)
const;
209 INLINE streampos normalize_streampos(streampos fpos)
const;
210 streampos pad_to_streampos(streampos fpos);
212 void add_new_subfile(Subfile *subfile,
int compression_level);
213 istream *open_read_subfile(Subfile *subfile);
214 string standardize_subfile_name(
const string &subfile_name)
const;
216 void clear_subfiles();
220 void check_signatures();
222 static INLINE
char tohex(
unsigned int nibble);
227 PendingSubfiles _new_subfiles;
228 PendingSubfiles _removed_subfiles;
229 PendingSubfiles _cert_special;
233 Certificates _signatures;
240 streampos _next_index;
241 streampos _last_index;
242 streampos _last_data_byte;
246 bool _timestamp_dirty;
247 bool _record_timestamp;
248 size_t _scale_factor;
249 size_t _new_scale_factor;
251 bool _encryption_flag;
252 string _encryption_password;
253 string _encryption_algorithm;
254 int _encryption_key_length;
255 int _encryption_iteration_count;
257 pifstream _read_file;
259 pofstream _write_file;
260 pfstream _read_write_file;
263 string _header_prefix;
268 static const char _header[];
269 static const size_t _header_size;
270 static const int _current_major_ver;
271 static const int _current_minor_ver;
273 static const char _encrypt_header[];
274 static const size_t _encrypt_header_size;
276 friend class Subfile;
279 #include "multifile.I" This class provides a locking wrapper around a combination ostream/istream pointer.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
This is our own Panda specialization on the default STL vector.
The name of a file, such as a texture file or an Egg file.
This class provides a locking wrapper around an arbitrary istream pointer.
A base class for all things that want to be reference-counted.
A file that contains a set of files.