diff options
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r-- | Source/cmArchiveWrite.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index a2aecac..c24c68e 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -16,6 +16,7 @@ #include <cmsys/Directory.hxx> #include <cmsys/FStream.hxx> #include <cm_libarchive.h> +#include "cm_get_date.h" //---------------------------------------------------------------------------- static std::string cm_archive_error_string(struct archive* a) @@ -271,10 +272,26 @@ bool cmArchiveWrite::AddFile(const char* file, cm_archive_entry_copy_pathname(e, dest); if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK) { - this->Error = "archive_read_disk_entry_from_file: "; + this->Error = "archive_read_disk_entry_from_file '"; + this->Error += file; + this->Error += "': "; this->Error += cm_archive_error_string(this->Disk); return false; } + if (!this->MTime.empty()) + { + time_t now; + time(&now); + time_t t = cm_get_date(now, this->MTime.c_str()); + if (t == -1) + { + this->Error = "unable to parse mtime '"; + this->Error += this->MTime; + this->Error += "'"; + return false; + } + archive_entry_set_mtime(e, t, 0); + } // Clear acl and xattr fields not useful for distribution. archive_entry_acl_clear(e); archive_entry_xattr_clear(e); |