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);
77 _timestamp = timestamp;
78 _timestamp_dirty =
true;
95 _record_timestamp = flag;
96 _timestamp_dirty =
true;
105 return _record_timestamp;
114 return _new_scale_factor;
130 express_cat.warning()
131 <<
"OpenSSL not compiled in; cannot generated encrypted multifiles.\n";
135 _encryption_flag = flag;
144 return _encryption_flag;
158 if (_encryption_password != encryption_password) {
159 if (!_new_subfiles.empty()) {
162 _encryption_password = encryption_password;
172 return _encryption_password;
191 if (_encryption_algorithm != encryption_algorithm) {
192 if (!_new_subfiles.empty()) {
195 _encryption_algorithm = encryption_algorithm;
205 return _encryption_algorithm;
223 if (_encryption_key_length != encryption_key_length) {
224 if (!_new_subfiles.empty()) {
227 _encryption_key_length = encryption_key_length;
237 return _encryption_key_length;
257 if (_encryption_iteration_count != encryption_iteration_count) {
259 _encryption_iteration_count = encryption_iteration_count;
268 return _encryption_iteration_count;
308 return std::string(_header, _header_size);
317 return _header_prefix;
324INLINE std::streampos Multifile::
325word_to_streampos(
size_t word)
const {
326 return (std::streampos)word * (std::streampos)_scale_factor;
333INLINE
size_t Multifile::
334streampos_to_word(std::streampos fpos)
const {
335 return (
size_t)((fpos + (std::streampos)_scale_factor - (std::streampos)1) / (std::streampos)_scale_factor);
342INLINE std::streampos Multifile::
343normalize_streampos(std::streampos fpos)
const {
344 return word_to_streampos(streampos_to_word(fpos));
350INLINE
char Multifile::
351tohex(
unsigned int nibble) {
356 return nibble - 10 +
'a';
362INLINE Multifile::Subfile::
370 _compression_level = 0;
379INLINE
bool Multifile::Subfile::
380operator < (
const Multifile::Subfile &other)
const {
384 nassertr(!is_cert_special() && !other.is_cert_special(),
false);
387 return _name < other._name;
395INLINE
bool Multifile::Subfile::
397 return (_flags & SF_deleted) != 0;
404INLINE
bool Multifile::Subfile::
405is_index_invalid()
const {
406 return (_flags & SF_index_invalid) != 0;
413INLINE
bool Multifile::Subfile::
414is_data_invalid()
const {
415 return (_flags & SF_data_invalid) != 0;
422INLINE
bool Multifile::Subfile::
423is_cert_special()
const {
424 return (_flags & SF_signature) != 0;
432INLINE std::streampos Multifile::Subfile::
433get_last_byte_pos()
const {
434 return (std::max)(_index_start + (std::streampos)_index_length,
435 _data_start + (std::streampos)_data_length) - (std::streampos)1;
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...
const Filename & get_multifile_name() const
Returns the filename of the Multifile, if it is available.
size_t get_scale_factor() const
Returns the internal scale factor for this Multifile.
int get_encryption_iteration_count() const
Returns the value that was specified by set_encryption_iteration_count().
void set_record_timestamp(bool record_timestamp)
Sets the flag indicating whether timestamps should be recorded within the Multifile or not.
bool flush()
Writes all contents of the Multifile to disk.
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...
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...
bool get_record_timestamp() const
Returns the flag indicating whether timestamps should be recorded within the Multifile or not.
bool is_write_valid() const
Returns true if the Multifile has been opened for write mode and there have been no errors,...
void set_timestamp(time_t timestamp)
Changes the overall mudification timestamp of 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().
void set_encryption_flag(bool flag)
Sets the flag indicating whether subsequently-added subfiles should be encrypted before writing them ...
time_t get_timestamp() const
Returns the modification timestamp of the overall Multifile.
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...
int get_encryption_key_length() const
Returns the encryption key length, in bits, that was specified by set_encryption_key_length().
void set_encryption_password(const std::string &encryption_password)
Specifies the password that will be used to encrypt subfiles subsequently added to the multifile,...
const std::string & get_header_prefix() const
Returns the string that preceded the Multifile header on the file, if any.
bool needs_repack() const
Returns true if the Multifile index is suboptimal and should be repacked.
const std::string & get_encryption_algorithm() const
Returns the encryption algorithm that was specified by set_encryption_algorithm().
get_magic_number
Returns a string with the first n bytes written to a Multifile, to identify it as a Multifile.
void set_multifile_name(const Filename &multifile_name)
Replaces the filename of the Multifile.
bool is_read_valid() const
Returns true if the Multifile has been opened for read mode and there have been no errors,...
void remove_subfile(int index)
Removes the nth subfile from the Multifile.
vector_uchar read_subfile(int index)
Returns a vector_uchar that contains the entire contents of the indicated subfile.
const std::string & get_encryption_password() const
Returns the password that will be used to encrypt subfiles subsequently added to the multifile.