From 5a223ebbc1c47d5c7d7d92200ba4fae8b8dcd89c Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 28 Sep 2009 17:46:28 +0000 Subject: [PATCH] C++ patching works now --- direct/src/plugin/p3dPackage.cxx | 4 +--- direct/src/plugin/p3dPatchfileReader.cxx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 59173b1ffc..3124a30c0c 100755 --- a/direct/src/plugin/p3dPackage.cxx +++ b/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; diff --git a/direct/src/plugin/p3dPatchfileReader.cxx b/direct/src/plugin/p3dPatchfileReader.cxx index 81e8cf2011..10854d13f1 100644 --- a/direct/src/plugin/p3dPatchfileReader.cxx +++ b/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());