19 return _multifile_name;
29 _multifile_name = multifile_name;
38 return (_read !=
nullptr);
47 return (_write !=
nullptr && !_write->fail());
56 return _needs_repack || (_scale_factor != _new_scale_factor);
84 _record_timestamp = flag;
85 _timestamp_dirty =
true;
94 return _record_timestamp;
103 return _new_scale_factor;
119 express_cat.warning()
120 <<
"OpenSSL not compiled in; cannot generated encrypted multifiles.\n";
123 #endif // HAVE_OPENSSL 124 _encryption_flag = flag;
133 return _encryption_flag;
147 if (_encryption_password != encryption_password) {
148 if (!_new_subfiles.empty()) {
151 _encryption_password = encryption_password;
161 return _encryption_password;
180 if (_encryption_algorithm != encryption_algorithm) {
181 if (!_new_subfiles.empty()) {
184 _encryption_algorithm = encryption_algorithm;
194 return _encryption_algorithm;
212 if (_encryption_key_length != encryption_key_length) {
213 if (!_new_subfiles.empty()) {
216 _encryption_key_length = encryption_key_length;
226 return _encryption_key_length;
246 if (_encryption_iteration_count != encryption_iteration_count) {
248 _encryption_iteration_count = encryption_iteration_count;
257 return _encryption_iteration_count;
295 INLINE std::string Multifile::
297 return std::string(_header, _header_size);
306 return _header_prefix;
313 INLINE std::streampos Multifile::
314 word_to_streampos(
size_t word)
const {
315 return (std::streampos)word * (std::streampos)_scale_factor;
322 INLINE
size_t Multifile::
323 streampos_to_word(std::streampos fpos)
const {
324 return (
size_t)((fpos + (std::streampos)_scale_factor - (std::streampos)1) / (std::streampos)_scale_factor);
331 INLINE std::streampos Multifile::
332 normalize_streampos(std::streampos fpos)
const {
333 return word_to_streampos(streampos_to_word(fpos));
339 INLINE
char Multifile::
340 tohex(
unsigned int nibble) {
345 return nibble - 10 +
'a';
351 INLINE Multifile::Subfile::
359 _compression_level = 0;
368 INLINE
bool Multifile::Subfile::
369 operator < (
const Multifile::Subfile &other)
const {
373 nassertr(!is_cert_special() && !other.is_cert_special(),
false);
376 return _name < other._name;
384 INLINE
bool Multifile::Subfile::
386 return (_flags & SF_deleted) != 0;
393 INLINE
bool Multifile::Subfile::
394 is_index_invalid()
const {
395 return (_flags & SF_index_invalid) != 0;
402 INLINE
bool Multifile::Subfile::
403 is_data_invalid()
const {
404 return (_flags & SF_data_invalid) != 0;
411 INLINE
bool Multifile::Subfile::
412 is_cert_special()
const {
413 return (_flags & SF_signature) != 0;
421 INLINE std::streampos Multifile::Subfile::
422 get_last_byte_pos()
const {
423 return std::max(_index_start + (std::streampos)_index_length,
424 _data_start + (std::streampos)_data_length) - (std::streampos)1;
const std::string & get_encryption_algorithm() const
Returns the encryption algorithm that was specified by set_encryption_algorithm().
size_t get_scale_factor() const
Returns the internal scale factor for this 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...
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.
void set_encryption_flag(bool flag)
Sets the flag indicating whether subsequently-added subfiles should be encrypted before writing them ...
const std::string & get_header_prefix() const
Returns the string that preceded the Multifile header on the file, if any.
bool is_write_valid() const
Returns true if the Multifile has been opened for write mode and there have been no errors,...
int find_subfile(const std::string &subfile_name) const
Returns the index of the subfile with the indicated name, or -1 if the named subfile is not within th...
int get_encryption_key_length() const
Returns the encryption key length, in bits, that was specified by set_encryption_key_length().
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.
bool get_encryption_flag() const
Returns the flag indicating whether subsequently-added subfiles should be encrypted before writing th...
int get_encryption_iteration_count() const
Returns the value that was specified by set_encryption_iteration_count().
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 is_read_valid() const
Returns true if the Multifile has been opened for read mode and there have been no errors,...
bool flush()
Writes all contents of the Multifile to disk.
bool get_record_timestamp() const
Returns the flag indicating whether timestamps should be recorded within the Multifile or not.
void set_encryption_password(const std::string &encryption_password)
Specifies the password that will be used to encrypt subfiles subsequently added to the multifile,...
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.
void set_encryption_algorithm(const std::string &encryption_algorithm)
Specifies the encryption algorithm that should be used for future calls to add_subfile().
const std::string & get_encryption_password() const
Returns the password that will be used to encrypt subfiles subsequently added to the multifile.
const Filename & get_multifile_name() const
Returns the filename of the Multifile, if it is available.
vector_uchar read_subfile(int index)
Returns a vector_uchar that contains the entire contents of the indicated subfile.