diff options
author | Manuel Núñez <ianmalcom@gmail.com> | 2017-10-02 09:42:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-10-24 15:04:25 (GMT) |
commit | 393e0fbe630a698d9c8c972059e5de1da727f76a (patch) | |
tree | 3dd4c327edbf8e22d6eff02c5124126b4eccb525 /Source/cmTimestamp.cxx | |
parent | 640709e7db054e90d5e6609eeb16a01af34b5a5a (diff) | |
download | CMake-393e0fbe630a698d9c8c972059e5de1da727f76a.zip CMake-393e0fbe630a698d9c8c972059e5de1da727f76a.tar.gz CMake-393e0fbe630a698d9c8c972059e5de1da727f76a.tar.bz2 |
cmTimestamp: For symlinks switch to timestamp of resolved path
ModifiedTime uses stat on UNIX which does resolve symlinks, however Windows implementation relies on GetFileAttributesExW which does not. Getting real file path before calling ModifiedTime will not change UNIX semantic and will fix Windows behavior.
Fixes: #17206
Diffstat (limited to 'Source/cmTimestamp.cxx')
-rw-r--r-- | Source/cmTimestamp.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 9fb79d9..e747adb 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -33,11 +33,13 @@ std::string cmTimestamp::FileModificationTime(const char* path, const std::string& formatString, bool utcFlag) { - if (!cmsys::SystemTools::FileExists(path)) { + std::string real_path = cmSystemTools::GetRealPath(path); + + if (!cmsys::SystemTools::FileExists(real_path)) { return std::string(); } - time_t mtime = cmsys::SystemTools::ModifiedTime(path); + time_t mtime = cmsys::SystemTools::ModifiedTime(real_path); return CreateTimestampFromTimeT(mtime, formatString, utcFlag); } |