mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
*** empty log message ***
This commit is contained in:
parent
12499cf062
commit
24c6a482ca
@ -71,6 +71,7 @@ init(PT(Buffer) buffer) {
|
|||||||
_frequency = extractor_frequency;
|
_frequency = extractor_frequency;
|
||||||
_token_board = new ExtractorTokenBoard;
|
_token_board = new ExtractorTokenBoard;
|
||||||
_buffer = buffer;
|
_buffer = buffer;
|
||||||
|
_threads_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <multifile.h>
|
#include <multifile.h>
|
||||||
#include <filename.h>
|
#include <filename.h>
|
||||||
|
#ifndef OLD_WAY
|
||||||
|
#include <extractor.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
@ -70,8 +73,14 @@ main(int argc, char *argv[]) {
|
|||||||
if (mfile.write(dest_file) == false)
|
if (mfile.write(dest_file) == false)
|
||||||
cerr << "Failed to write: " << dest_file << endl;
|
cerr << "Failed to write: " << dest_file << endl;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef OLD_WAY
|
||||||
mfile.read(dest_file);
|
mfile.read(dest_file);
|
||||||
mfile.extract_all(rel_path);
|
mfile.extract_all(rel_path);
|
||||||
|
#else
|
||||||
|
Extractor extor;
|
||||||
|
extor.set_frequency(0);
|
||||||
|
extor.extract(dest_file, rel_path);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -308,6 +308,7 @@ add_fixed_string(const string &str, size_t size) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void Datagram::
|
INLINE void Datagram::
|
||||||
pad_bytes(size_t size) {
|
pad_bytes(size_t size) {
|
||||||
|
nassertv((int)size >= 0);
|
||||||
_message += string(size, '\0');
|
_message += string(size, '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,6 +320,7 @@ pad_bytes(size_t size) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void Datagram::
|
INLINE void Datagram::
|
||||||
append_data(const void *data, size_t size) {
|
append_data(const void *data, size_t size) {
|
||||||
|
nassertv((int)size >= 0);
|
||||||
_message += string((const char *)data, size);
|
_message += string((const char *)data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,6 +466,7 @@ get_fixed_string(size_t size) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void DatagramIterator::
|
void DatagramIterator::
|
||||||
skip_bytes(size_t size) {
|
skip_bytes(size_t size) {
|
||||||
|
nassertv((int)size >= 0);
|
||||||
nassertv(_current_index + size <= _datagram.get_length());
|
nassertv(_current_index + size <= _datagram.get_length());
|
||||||
_current_index += size;
|
_current_index += size;
|
||||||
}
|
}
|
||||||
@ -478,6 +479,7 @@ skip_bytes(size_t size) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
string DatagramIterator::
|
string DatagramIterator::
|
||||||
extract_bytes(size_t size) {
|
extract_bytes(size_t size) {
|
||||||
|
nassertr((int)size >= 0, "");
|
||||||
nassertr(_current_index + size <= _datagram.get_length(), "");
|
nassertr(_current_index + size <= _datagram.get_length(), "");
|
||||||
int start = _current_index;
|
int start = _current_index;
|
||||||
|
|
||||||
@ -516,3 +518,14 @@ const Datagram &DatagramIterator::
|
|||||||
get_datagram() const {
|
get_datagram() const {
|
||||||
return _datagram;
|
return _datagram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DatagramIterator::get_current_index
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the current position within the datagram of the
|
||||||
|
// next piece of data to extract.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
size_t DatagramIterator::
|
||||||
|
get_current_index() const {
|
||||||
|
return _current_index;
|
||||||
|
}
|
||||||
|
@ -53,6 +53,7 @@ public:
|
|||||||
int get_remaining_size() const;
|
int get_remaining_size() const;
|
||||||
|
|
||||||
const Datagram &get_datagram() const;
|
const Datagram &get_datagram() const;
|
||||||
|
size_t get_current_index() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Datagram &_datagram;
|
const Datagram &_datagram;
|
||||||
|
@ -82,6 +82,8 @@ parse_header_length(char *&start, int &size) {
|
|||||||
int bytes_so_far = _datagram.get_length();
|
int bytes_so_far = _datagram.get_length();
|
||||||
if (bytes_so_far + size < _header_length_buf_length) {
|
if (bytes_so_far + size < _header_length_buf_length) {
|
||||||
_datagram.append_data(start, size);
|
_datagram.append_data(start, size);
|
||||||
|
start += size;
|
||||||
|
size = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,13 +91,18 @@ parse_header_length(char *&start, int &size) {
|
|||||||
nassertr((int)_datagram.get_length() == _header_length_buf_length, false);
|
nassertr((int)_datagram.get_length() == _header_length_buf_length, false);
|
||||||
|
|
||||||
// Advance start and adjust size
|
// Advance start and adjust size
|
||||||
start += _header_length_buf_length;
|
nassertr(_header_length_buf_length >= bytes_so_far, false);
|
||||||
|
start += (_header_length_buf_length - bytes_so_far);
|
||||||
nassertr(size >= _header_length_buf_length, false);
|
nassertr(size >= _header_length_buf_length, false);
|
||||||
size -= _header_length_buf_length;
|
size -= (_header_length_buf_length - bytes_so_far);
|
||||||
|
|
||||||
DatagramIterator di(_datagram);
|
DatagramIterator di(_datagram);
|
||||||
_header_length = di.get_int32();
|
_header_length = di.get_int32();
|
||||||
|
|
||||||
|
express_cat.debug()
|
||||||
|
<< "Multifile::Memfile::parse_header_length() - header length: "
|
||||||
|
<< _header_length << endl;
|
||||||
|
|
||||||
nassertr(_header_length > _header_length_buf_length + (int)sizeof(_buffer_length), false);
|
nassertr(_header_length > _header_length_buf_length + (int)sizeof(_buffer_length), false);
|
||||||
|
|
||||||
_header_length_parsed = true;
|
_header_length_parsed = true;
|
||||||
@ -140,6 +147,12 @@ parse_header(char *&start, int& size) {
|
|||||||
_name = di.extract_bytes(_header_length - _header_length_buf_length -
|
_name = di.extract_bytes(_header_length - _header_length_buf_length -
|
||||||
sizeof(_buffer_length));
|
sizeof(_buffer_length));
|
||||||
_buffer_length = di.get_int32();
|
_buffer_length = di.get_int32();
|
||||||
|
nassertr(_buffer_length >= 0, false);
|
||||||
|
|
||||||
|
express_cat.debug()
|
||||||
|
<< "Multifile::Memfile::parse_header() - Got a header for mem "
|
||||||
|
<< "file: " << _name << " header length: " << _header_length
|
||||||
|
<< " buffer length: " << _buffer_length << endl;
|
||||||
|
|
||||||
// Advance start pointer to the end of the header
|
// Advance start pointer to the end of the header
|
||||||
start += tsize;
|
start += tsize;
|
||||||
@ -291,6 +304,9 @@ write(char *&start, int &size, const Filename &rel_path) {
|
|||||||
Filename name = rel_path.get_fullpath() + _name.get_fullpath();
|
Filename name = rel_path.get_fullpath() + _name.get_fullpath();
|
||||||
name.set_binary();
|
name.set_binary();
|
||||||
name.make_dir();
|
name.make_dir();
|
||||||
|
express_cat.debug()
|
||||||
|
<< "Multifile::Memfile::write() - Opening mem file: " << name
|
||||||
|
<< " for writing" << endl;
|
||||||
if ((_file_open = name.open_write(_write_stream)) == false) {
|
if ((_file_open = name.open_write(_write_stream)) == false) {
|
||||||
express_cat.error()
|
express_cat.error()
|
||||||
<< "Multfile::Memfile::write() - Couldn't open file: "
|
<< "Multfile::Memfile::write() - Couldn't open file: "
|
||||||
@ -303,6 +319,7 @@ write(char *&start, int &size, const Filename &rel_path) {
|
|||||||
// Don't write more than the buffer length
|
// Don't write more than the buffer length
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int tsize = size;
|
int tsize = size;
|
||||||
|
nassertr(_buffer_length >= _bytes_written, false);
|
||||||
int missing_bytes = _buffer_length - _bytes_written;
|
int missing_bytes = _buffer_length - _bytes_written;
|
||||||
if (size >= missing_bytes) {
|
if (size >= missing_bytes) {
|
||||||
tsize = missing_bytes;
|
tsize = missing_bytes;
|
||||||
@ -312,10 +329,14 @@ write(char *&start, int &size, const Filename &rel_path) {
|
|||||||
_write_stream.write(start, tsize);
|
_write_stream.write(start, tsize);
|
||||||
start += tsize;
|
start += tsize;
|
||||||
_bytes_written += tsize;
|
_bytes_written += tsize;
|
||||||
|
nassertr(size >= tsize, false);
|
||||||
size -= tsize;
|
size -= tsize;
|
||||||
|
|
||||||
if (done == true)
|
if (done == true) {
|
||||||
_write_stream.close();
|
_write_stream.close();
|
||||||
|
express_cat.debug()
|
||||||
|
<< "Multifile::Memfile::write() - Closing mem file" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
@ -406,6 +427,11 @@ parse_header(char *&start, int &size) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_num_mfiles = di.get_int32();
|
_num_mfiles = di.get_int32();
|
||||||
|
if (_num_mfiles <= 0) {
|
||||||
|
express_cat.debug()
|
||||||
|
<< "Multifile::parse_header() - No memfiles in multifile"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Advance start pointer to the end of the header
|
// Advance start pointer to the end of the header
|
||||||
start += tsize;
|
start += tsize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user