From f29c43153c9d8b1075baed7b9001652a98c7a47d Mon Sep 17 00:00:00 2001 From: Mike Goslin Date: Fri, 15 Dec 2000 04:16:14 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/downloader/extractor.cxx | 2 ++ panda/src/express/multifile.cxx | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index 427171584d..fff4372bc7 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -101,6 +101,7 @@ initiate(Filename &source_file, const Filename &rel_path) { //////////////////////////////////////////////////////////////////// int Extractor:: run(void) { + nassertr(_mfile != NULL, ES_error); // See if there is anything left in the source file if (_read_all_input == false) { _read_stream.read(_buffer->_buffer, _buffer->get_length()); @@ -119,6 +120,7 @@ run(void) { _read_stream.close(); _source_file.unlink(); delete _mfile; + _mfile = NULL; return ES_success; } return ES_ok; diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 07ae31d4b9..520c2bd732 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -300,17 +300,23 @@ write_to_multifile(ofstream &write_stream) { bool Multifile::Memfile:: write(char *&start, int &size, const Filename &rel_path) { // Make sure we've got a complete header first - if (parse_header(start, size) == false) + if (parse_header(start, size) == false) { + if (express_cat.is_debug()) + express_cat.debug() + << "Multifile::Memfile::write() - parse_header() == false" + << endl; return false; + } // Try to open the file for writing if (_file_open == false) { Filename name = rel_path.get_fullpath() + _name.get_fullpath(); name.set_binary(); name.make_dir(); - express_cat.debug() - << "Multifile::Memfile::write() - Opening mem file: " << name - << " for writing" << endl; + if (express_cat.is_debug()) + express_cat.debug() + << "Multifile::Memfile::write() - Opening mem file: " << name + << " for writing" << endl; if ((_file_open = name.open_write(_write_stream)) == false) { express_cat.error() << "Multfile::Memfile::write() - Couldn't open file: " @@ -366,6 +372,8 @@ Multifile(void) { Multifile:: ~Multifile(void) { _files.erase(_files.begin(), _files.end()); + if (_current_mfile != NULL) + delete _current_mfile; } //////////////////////////////////////////////////////////////////// @@ -584,16 +592,14 @@ write(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; - while (_num_mfiles > 0) { - if (_current_mfile == NULL) + if (_current_mfile == NULL) { _current_mfile = new Memfile; + } if (_current_mfile->write(start, size, rel_path) == true) { _num_mfiles--; delete _current_mfile; - // _current_mfile->reset(); + _current_mfile = NULL; } else return false; }