From e0f020bc0be1961ce48bc3b843d635eb6e4a4c14 Mon Sep 17 00:00:00 2001 From: Mike Goslin Date: Wed, 11 Oct 2000 02:00:11 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/downloader/extractor.cxx | 20 +++++++++++++------- panda/src/downloader/extractor.h | 4 ++-- panda/src/express/multifile.cxx | 15 ++++++++------- panda/src/express/multifile.h | 4 ++-- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index 65df13ffff..59a2a983b2 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -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(); diff --git a/panda/src/downloader/extractor.h b/panda/src/downloader/extractor.h index 2409b65999..74e0c3675b 100644 --- a/panda/src/downloader/extractor.h +++ b/panda/src/downloader/extractor.h @@ -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); diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 23fb14dbe1..c34327c52e 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -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; diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index 5cb43dc34d..6d83e35897 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -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: