summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-25 12:52:08 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-04-25 12:52:15 (GMT)
commit52c11e4f646404ea75e013c358196f64cb1a925e (patch)
tree9d27e148fe3cd210d84c84e8af12411a5ff35280 /Source
parent92eae6b72d5e57c8f42781b8c40545d6db348488 (diff)
parent6dcd1bfa39684c952730904a43e268f42bf98301 (diff)
downloadCMake-52c11e4f646404ea75e013c358196f64cb1a925e.zip
CMake-52c11e4f646404ea75e013c358196f64cb1a925e.tar.gz
CMake-52c11e4f646404ea75e013c358196f64cb1a925e.tar.bz2
Merge topic 'file_install_always_out_of_date_fix'
6dcd1bfa39 file(INSTALL): Preserve file time when writing NTFS alternate stream Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1992
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 0d31070..6c1a869 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -1129,14 +1129,26 @@ protected:
if (permissions) {
#ifdef WIN32
if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
+ // Store the mode in an NTFS alternate stream.
std::string mode_t_adt_filename =
std::string(toFile) + ":cmake_mode_t";
+ // Writing to an NTFS alternate stream changes the modification
+ // time, so we need to save and restore its original value.
+ cmSystemToolsFileTime* file_time_orig = cmSystemTools::FileTimeNew();
+ cmSystemTools::FileTimeGet(toFile, file_time_orig);
+
cmsys::ofstream permissionStream(mode_t_adt_filename.c_str());
if (permissionStream) {
permissionStream << std::oct << permissions << std::endl;
}
+
+ permissionStream.close();
+
+ cmSystemTools::FileTimeSet(toFile, file_time_orig);
+
+ cmSystemTools::FileTimeDelete(file_time_orig);
}
#endif