mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user