add better error checking and run from correct directory.
This commit is contained in:
parent
36197f45ca
commit
70dbbcc542
|
@ -172,12 +172,13 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName,
|
||||||
{
|
{
|
||||||
int res = ARCHIVE_OK;
|
int res = ARCHIVE_OK;
|
||||||
#define CHECK_ARCHIVE_ERROR(res, msg) \
|
#define CHECK_ARCHIVE_ERROR(res, msg) \
|
||||||
if(res != ARCHIVE_OK)\
|
if(res != ARCHIVE_OK) \
|
||||||
{\
|
{\
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, msg \
|
cmCPackLogger(cmCPackLog::LOG_ERROR, msg \
|
||||||
<< archive_error_string(a) \
|
<< archive_error_string(a) \
|
||||||
|
<< cmSystemTools::GetLastSystemError() \
|
||||||
|
<< " " << res \
|
||||||
<< "\n"); \
|
<< "\n"); \
|
||||||
return 0; \
|
|
||||||
}
|
}
|
||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
|
||||||
<< (toplevel ? toplevel : "(NULL)") << std::endl);
|
<< (toplevel ? toplevel : "(NULL)") << std::endl);
|
||||||
|
@ -198,9 +199,13 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName,
|
||||||
CHECK_ARCHIVE_ERROR(res, "archive_write_open:");
|
CHECK_ARCHIVE_ERROR(res, "archive_write_open:");
|
||||||
// create a new disk struct
|
// create a new disk struct
|
||||||
struct archive* disk = archive_read_disk_new();
|
struct archive* disk = archive_read_disk_new();
|
||||||
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
res = archive_read_disk_set_standard_lookup(disk);
|
res = archive_read_disk_set_standard_lookup(disk);
|
||||||
|
#endif
|
||||||
CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:");
|
CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:");
|
||||||
std::vector<std::string>::const_iterator fileIt;
|
std::vector<std::string>::const_iterator fileIt;
|
||||||
|
std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
|
||||||
|
cmSystemTools::ChangeDirectory(toplevel);
|
||||||
for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
|
for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
|
||||||
{
|
{
|
||||||
// create a new entry for each file
|
// create a new entry for each file
|
||||||
|
@ -246,6 +251,7 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName,
|
||||||
}
|
}
|
||||||
archive_entry_free(entry);
|
archive_entry_free(entry);
|
||||||
}
|
}
|
||||||
|
cmSystemTools::ChangeDirectory(dir.c_str());
|
||||||
// close the archive and finish the write
|
// close the archive and finish the write
|
||||||
archive_write_close(a);
|
archive_write_close(a);
|
||||||
archive_write_finish(a);
|
archive_write_finish(a);
|
||||||
|
|
Loading…
Reference in New Issue