Browse Source

C++ patching works now

David Rose 16 years ago
parent
commit
5a223ebbc1
2 changed files with 14 additions and 5 deletions
  1. 1 3
      direct/src/plugin/p3dPackage.cxx
  2. 13 2
      direct/src/plugin/p3dPatchfileReader.cxx

+ 1 - 3
direct/src/plugin/p3dPackage.cxx

@@ -850,9 +850,6 @@ follow_install_plans(bool download_finished) {
       _current_step_effort = step->get_effort();
 
       InstallToken token = step->do_step(download_finished);
-      nout << step << ":";
-      step->output(nout);
-      nout << " returned " << token << "\n";
       switch (token) {
       case IT_step_failed:
         // This plan has failed.
@@ -1530,6 +1527,7 @@ do_step(bool download_finished) {
 
   // Close and verify.
   _reader.close();
+
   if (!_reader.get_success()) {
     nout << "Patching failed\n";
     return IT_step_failed;

+ 13 - 2
direct/src/plugin/p3dPatchfileReader.cxx

@@ -194,7 +194,9 @@ step() {
 //     Function: P3DPatchfileReader::close
 //       Access: Public
 //  Description: Closes the previously-opened files, and moves the
-//               output file into place.
+//               output file into place.  This also deletes the
+//               patchfile, assuming it will not be needed after it
+//               has been used.
 ////////////////////////////////////////////////////////////////////
 void P3DPatchfileReader::
 close() {
@@ -202,15 +204,24 @@ close() {
     return;
   }
 
+  _is_open = false;
+
   _patch_in.close();
   _source_in.close();
   _target_out.close();
+  
+  // Delete the patchfile.
+  string patch_pathname = _patchfile.get_pathname(_package_dir);
+#ifdef _WIN32
+  // Windows can't delete a file if it's read-only.
+  chmod(patch_pathname.c_str(), 0644);
+#endif
+  unlink(patch_pathname.c_str());
 
   if (_success) {
     // Move the output file onto the target file.
     string target_pathname = _target.get_pathname(_package_dir);
 #ifdef _WIN32
-    // Windows can't delete a file if it's read-only.
     chmod(target_pathname.c_str(), 0644);
 #endif
     unlink(target_pathname.c_str());