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