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
This commit is contained in:
Manuel Núñez authored and Brad King committed 2017-10-24 11:04:25 -04:00
1 parent 640709e7db
commit 393e0fbe63
1 file changed
+4 -2
+4 -2
View File
@@ -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);
}