mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
*** empty log message ***
This commit is contained in:
parent
041cec32ec
commit
e0f020bc0b
@ -26,14 +26,17 @@
|
||||
class ExtractorToken : public ReferenceCount {
|
||||
public:
|
||||
INLINE ExtractorToken(uint id, const Filename &source_file,
|
||||
const string &event_name) {
|
||||
const string &event_name,
|
||||
const Filename &rel_path) {
|
||||
_id = id;
|
||||
_source_file = source_file;
|
||||
_event_name = event_name;
|
||||
_rel_path = rel_path;
|
||||
}
|
||||
int _id;
|
||||
Filename _source_file;
|
||||
string _event_name;
|
||||
Filename _rel_path;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -88,7 +91,8 @@ Extractor::
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int Extractor::
|
||||
request_extract(const Filename &source_file, const string &event_name) {
|
||||
request_extract(const Filename &source_file, const string &event_name,
|
||||
const Filename &rel_path) {
|
||||
|
||||
PT(ExtractorToken) tok;
|
||||
if (_threads_enabled) {
|
||||
@ -115,7 +119,8 @@ request_extract(const Filename &source_file, const string &event_name) {
|
||||
<< "Extract requested for file: " << source_file << endl;
|
||||
}
|
||||
|
||||
tok = new ExtractorToken(_next_token++, source_file, event_name);
|
||||
tok = new ExtractorToken(_next_token++, source_file, event_name,
|
||||
rel_path);
|
||||
_token_board->_waiting.insert(tok);
|
||||
|
||||
_request_cond->signal();
|
||||
@ -135,7 +140,8 @@ request_extract(const Filename &source_file, const string &event_name) {
|
||||
<< "Extract requested for file: " << source_file << endl;
|
||||
}
|
||||
|
||||
tok = new ExtractorToken(_next_token++, source_file, event_name);
|
||||
tok = new ExtractorToken(_next_token++, source_file, event_name,
|
||||
rel_path);
|
||||
_token_board->_waiting.insert(tok);
|
||||
process_request();
|
||||
}
|
||||
@ -161,7 +167,7 @@ process_request() {
|
||||
// If there is actually a request token - process it
|
||||
while (!_token_board->_waiting.is_empty()) {
|
||||
PT(ExtractorToken) tok = _token_board->_waiting.extract();
|
||||
if (extract(tok->_source_file)) {
|
||||
if (extract(tok->_source_file, tok->_rel_path)) {
|
||||
_token_board->_done.insert(tok);
|
||||
|
||||
// Throw a "done" event now.
|
||||
@ -188,7 +194,7 @@ process_request() {
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Extractor::
|
||||
extract(Filename &source_file) {
|
||||
extract(Filename &source_file, const Filename &rel_path) {
|
||||
|
||||
// Open source file
|
||||
ifstream read_stream;
|
||||
@ -229,7 +235,7 @@ extract(Filename &source_file) {
|
||||
// Write to the out file
|
||||
char *start = _buffer->_buffer;
|
||||
int size = source_buffer_length;
|
||||
if (mfile.write_extract(start, size) == true)
|
||||
if (mfile.write_extract(start, size, rel_path) == true)
|
||||
handled_all_input = true;
|
||||
|
||||
nap();
|
||||
|
@ -29,9 +29,9 @@ public:
|
||||
~Extractor(void);
|
||||
|
||||
int request_extract(const Filename &source_file,
|
||||
const string &event_name);
|
||||
const string &event_name, const Filename &rel_path = "");
|
||||
|
||||
bool extract(Filename &source_file);
|
||||
bool extract(Filename &source_file, const Filename &rel_path);
|
||||
|
||||
private:
|
||||
void init(PT(Buffer) buffer);
|
||||
|
@ -281,19 +281,20 @@ write_to_multifile(ofstream &write_stream) {
|
||||
// Advances the start pointer as it writes.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Multifile::Memfile::
|
||||
write(char *&start, int &size) {
|
||||
write(char *&start, int &size, const Filename &rel_path) {
|
||||
// Make sure we've got a complete header first
|
||||
if (parse_header(start, size) == false)
|
||||
return false;
|
||||
|
||||
// Try to open the file for writing
|
||||
if (_file_open == false) {
|
||||
_name.set_binary();
|
||||
_name.make_dir();
|
||||
if ((_file_open = _name.open_write(_write_stream)) == false) {
|
||||
Filename name = rel_path.get_fullpath() + _name.get_fullpath();
|
||||
name.set_binary();
|
||||
name.make_dir();
|
||||
if ((_file_open = name.open_write(_write_stream)) == false) {
|
||||
express_cat.error()
|
||||
<< "Multfile::Memfile::write() - Couldn't open file: "
|
||||
<< _name << endl;
|
||||
<< name << endl;
|
||||
return false;
|
||||
}
|
||||
_file_open = true;
|
||||
@ -573,13 +574,13 @@ write(char *&start, int &size) {
|
||||
// extracted to disk files.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Multifile::
|
||||
write_extract(char *&start, int &size) {
|
||||
write_extract(char *&start, int &size, const Filename &rel_path) {
|
||||
if (parse_header(start, size) == false)
|
||||
return false;
|
||||
if (_current_mfile == (Memfile *)0L)
|
||||
_current_mfile = new Memfile;
|
||||
for (;;) {
|
||||
if (_current_mfile->write(start, size) == false)
|
||||
if (_current_mfile->write(start, size, rel_path) == false)
|
||||
return false;
|
||||
if (++_mfiles_written == _num_mfiles)
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
bool read(Filename &name);
|
||||
bool write(Filename name);
|
||||
bool write(char *&start, int &size);
|
||||
bool write_extract(char *&start, int &size);
|
||||
bool write_extract(char *&start, int &size, const Filename &rel_path = "");
|
||||
bool extract(const Filename &name, const Filename &rel_path = "");
|
||||
void extract_all(const Filename &rel_path = "");
|
||||
|
||||
@ -66,7 +66,7 @@ private:
|
||||
bool read_from_multifile(ifstream &read_stream);
|
||||
bool write(const Filename &rel_path);
|
||||
void write_to_multifile(ofstream &write_stream);
|
||||
bool write(char *&start, int &size);
|
||||
bool write(char *&start, int &size, const Filename &rel_path = "");
|
||||
void reset(void);
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user