diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-11-09 14:58:03 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-11-09 14:58:03 (GMT) |
commit | 70dbbcc54278ef4f618ab316c67dcae0903fd6e2 (patch) | |
tree | 6753871dca04b2a6ba68501a1f45e063d5395746 /Source/CPack/cmCPackArchiveGenerator.cxx | |
parent | 36197f45cac58bd24234a0cbe94e2272f8f7590b (diff) | |
download | CMake-70dbbcc54278ef4f618ab316c67dcae0903fd6e2.zip CMake-70dbbcc54278ef4f618ab316c67dcae0903fd6e2.tar.gz CMake-70dbbcc54278ef4f618ab316c67dcae0903fd6e2.tar.bz2 |
add better error checking and run from correct directory.
Diffstat (limited to 'Source/CPack/cmCPackArchiveGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackArchiveGenerator.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 86c6148..e205419 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -172,12 +172,13 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, { int res = ARCHIVE_OK; #define CHECK_ARCHIVE_ERROR(res, msg) \ - if(res != ARCHIVE_OK)\ + if(res != ARCHIVE_OK) \ {\ cmCPackLogger(cmCPackLog::LOG_ERROR, msg \ << archive_error_string(a) \ + << cmSystemTools::GetLastSystemError() \ + << " " << res \ << "\n"); \ - return 0; \ } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << (toplevel ? toplevel : "(NULL)") << std::endl); @@ -198,9 +199,13 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, CHECK_ARCHIVE_ERROR(res, "archive_write_open:"); // create a new disk struct struct archive* disk = archive_read_disk_new(); +#if !defined(_WIN32) || defined(__CYGWIN__) res = archive_read_disk_set_standard_lookup(disk); +#endif CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:"); std::vector<std::string>::const_iterator fileIt; + std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(toplevel); for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) { // create a new entry for each file @@ -208,7 +213,7 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, // Get the relative path to the file std::string rp = cmSystemTools::RelativePath(toplevel, fileIt->c_str()); // Set the name of the entry to the file name - archive_entry_set_pathname(entry, rp.c_str()); + archive_entry_set_pathname(entry, rp.c_str()); res = archive_read_disk_entry_from_file(disk, entry, -1, 0); CHECK_ARCHIVE_ERROR(res, "archive_read_disk_entry_from_file:"); // write entry header @@ -246,6 +251,7 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, } archive_entry_free(entry); } + cmSystemTools::ChangeDirectory(dir.c_str()); // close the archive and finish the write archive_write_close(a); archive_write_finish(a); |