24 return _multifile_name;
37 _multifile_name = multifile_name;
61 return (_write != (ostream *)NULL && !_write->fail());
72 return _needs_repack || (_scale_factor != _new_scale_factor);
109 _record_timestamp = flag;
110 _timestamp_dirty =
true;
122 return _record_timestamp;
133 return _new_scale_factor;
155 express_cat.warning()
156 <<
"OpenSSL not compiled in; cannot generated encrypted multifiles.\n";
159 #endif // HAVE_OPENSSL
160 _encryption_flag = flag;
173 return _encryption_flag;
191 if (_encryption_password != encryption_password) {
192 if (!_new_subfiles.empty()) {
195 _encryption_password = encryption_password;
208 return _encryption_password;
233 if (_encryption_algorithm != encryption_algorithm) {
234 if (!_new_subfiles.empty()) {
237 _encryption_algorithm = encryption_algorithm;
249 return _encryption_algorithm;
272 if (_encryption_key_length != encryption_key_length) {
273 if (!_new_subfiles.empty()) {
276 _encryption_key_length = encryption_key_length;
288 return _encryption_key_length;
314 if (_encryption_iteration_count != encryption_iteration_count) {
316 _encryption_iteration_count = encryption_iteration_count;
328 return _encryption_iteration_count;
377 return string(_header, _header_size);
388 return _header_prefix;
397 INLINE streampos Multifile::
398 word_to_streampos(
size_t word)
const {
399 return (streampos)word * (streampos)_scale_factor;
408 INLINE
size_t Multifile::
409 streampos_to_word(streampos fpos)
const {
410 return (
size_t)((fpos + (streampos)_scale_factor - (streampos)1) / (streampos)_scale_factor);
420 INLINE streampos Multifile::
421 normalize_streampos(streampos fpos)
const {
422 return word_to_streampos(streampos_to_word(fpos));
430 INLINE
char Multifile::
431 tohex(
unsigned int nibble) {
436 return nibble - 10 +
'a';
444 INLINE Multifile::Subfile::
450 _source = (istream *)NULL;
452 _compression_level = 0;
464 INLINE
bool Multifile::Subfile::
465 operator < (
const Multifile::Subfile &other)
const {
469 nassertr(!is_cert_special() && !other.is_cert_special(),
false);
473 return _name < other._name;
485 INLINE
bool Multifile::Subfile::
487 return (_flags & SF_deleted) != 0;
496 INLINE
bool Multifile::Subfile::
497 is_index_invalid()
const {
498 return (_flags & SF_index_invalid) != 0;
508 INLINE
bool Multifile::Subfile::
509 is_data_invalid()
const {
510 return (_flags & SF_data_invalid) != 0;
520 INLINE
bool Multifile::Subfile::
521 is_cert_special()
const {
522 return (_flags & SF_signature) != 0;
532 INLINE streampos Multifile::Subfile::
533 get_last_byte_pos()
const {
534 return max(_index_start + (streampos)_index_length,
535 _data_start + (streampos)_data_length) - (streampos)1;
int find_subfile(const string &subfile_name) const
Returns the index of the subfile with the indicated name, or -1 if the named subfile is not within th...
void set_encryption_password(const string &encryption_password)
Specifies the password that will be used to encrypt subfiles subsequently added to the multifile...
void set_encryption_key_length(int encryption_key_length)
Specifies the length of the key, in bits, that should be used to encrypt the stream in future calls t...
int get_encryption_iteration_count() const
Returns the value that was specified by set_encryption_iteration_count().
const string & get_encryption_password() const
Returns the password that will be used to encrypt subfiles subsequently added to the multifile...
string read_subfile(int index)
Returns a string that contains the entire contents of the indicated subfile.
void set_encryption_flag(bool flag)
Sets the flag indicating whether subsequently-added subfiles should be encrypted before writing them ...
void set_encryption_algorithm(const string &encryption_algorithm)
Specifies the encryption algorithm that should be used for future calls to add_subfile().
bool get_record_timestamp() const
Returns the flag indicating whether timestamps should be recorded within the Multifile or not...
size_t get_scale_factor() const
Returns the internal scale factor for this Multifile.
bool is_read_valid() const
Returns true if the Multifile has been opened for read mode and there have been no errors...
bool is_write_valid() const
Returns true if the Multifile has been opened for write mode and there have been no errors...
const string & get_header_prefix() const
Returns the string that preceded the Multifile header on the file, if any.
void set_multifile_name(const Filename &multifile_name)
Replaces the filename of the Multifile.
The name of a file, such as a texture file or an Egg file.
static string get_magic_number()
Returns a string with the first n bytes written to a Multifile, to identify it as a Multifile...
This class provides a locking wrapper around an arbitrary istream pointer.
void set_encryption_iteration_count(int encryption_iteration_count)
Specifies the number of times to repeatedly hash the key before writing it to the stream in future ca...
bool flush()
Writes all contents of the Multifile to disk.
void set_record_timestamp(bool record_timestamp)
Sets the flag indicating whether timestamps should be recorded within the Multifile or not...
void remove_subfile(int index)
Removes the nth subfile from the Multifile.
const string & get_encryption_algorithm() const
Returns the encryption algorithm that was specified by set_encryption_algorithm().
int get_encryption_key_length() const
Returns the encryption key length, in bits, that was specified by set_encryption_key_length().
bool get_encryption_flag() const
Returns the flag indicating whether subsequently-added subfiles should be encrypted before writing th...
time_t get_timestamp() const
Returns the modification timestamp of the overall Multifile.
bool needs_repack() const
Returns true if the Multifile index is suboptimal and should be repacked.
const Filename & get_multifile_name() const
Returns the filename of the Multifile, if it is available.