Browse Source

*** empty log message ***

Mike Goslin 25 years ago
parent
commit
f29c43153c
2 changed files with 17 additions and 9 deletions
  1. 2 0
      panda/src/downloader/extractor.cxx
  2. 15 9
      panda/src/express/multifile.cxx

+ 2 - 0
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;

+ 15 - 9
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;
   }