diff options
author | Kasper Laudrup <you@example.com> | 2022-03-15 18:27:54 (GMT) |
---|---|---|
committer | Kasper Laudrup <you@example.com> | 2022-03-23 13:41:34 (GMT) |
commit | 0b7fd783f82639ba129e62edeac0de6594542708 (patch) | |
tree | 6958f1bb75909c6fa703927b16d184d15a5de9b5 /Source/cmSystemTools.cxx | |
parent | f692cba34b758f5c308c3fd659c438ce022a0a80 (diff) | |
download | CMake-0b7fd783f82639ba129e62edeac0de6594542708.zip CMake-0b7fd783f82639ba129e62edeac0de6594542708.tar.gz CMake-0b7fd783f82639ba129e62edeac0de6594542708.tar.bz2 |
cmake -E tar: Add --touch option
Similar to GNU tar add a --touch option to the tar extract command to
skip extracting the timestamps from the files in the archive
effectively touching them as if they were just created.
Issue: #22746
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a5dfa4c..cb32172 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1821,6 +1821,7 @@ bool copy_data(struct archive* ar, struct archive* aw) bool extract_tar(const std::string& outFileName, const std::vector<std::string>& files, bool verbose, + cmSystemTools::cmTarExtractTimestamps extractTimestamps, bool extract) { cmLocaleRAII localeRAII; @@ -1879,10 +1880,12 @@ bool extract_tar(const std::string& outFileName, cmSystemTools::Stdout("\n"); } if (extract) { - r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME); - if (r != ARCHIVE_OK) { - ArchiveError("Problem with archive_write_disk_set_options(): ", ext); - break; + if (extractTimestamps == cmSystemTools::cmTarExtractTimestamps::Yes) { + r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME); + if (r != ARCHIVE_OK) { + ArchiveError("Problem with archive_write_disk_set_options(): ", ext); + break; + } } r = archive_write_header(ext, entry); @@ -1942,13 +1945,15 @@ bool extract_tar(const std::string& outFileName, bool cmSystemTools::ExtractTar(const std::string& outFileName, const std::vector<std::string>& files, + cmTarExtractTimestamps extractTimestamps, bool verbose) { #if !defined(CMAKE_BOOTSTRAP) - return extract_tar(outFileName, files, verbose, true); + return extract_tar(outFileName, files, verbose, extractTimestamps, true); #else (void)outFileName; (void)files; + (void)extractTimestamps; (void)verbose; return false; #endif @@ -1959,7 +1964,8 @@ bool cmSystemTools::ListTar(const std::string& outFileName, bool verbose) { #if !defined(CMAKE_BOOTSTRAP) - return extract_tar(outFileName, files, verbose, false); + return extract_tar(outFileName, files, verbose, cmTarExtractTimestamps::Yes, + false); #else (void)outFileName; (void)files; |