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
2017-10-02 11:42:19 +02:00
committed by Brad King
parent 640709e7db
commit 393e0fbe63

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);
}