From a368a5946744191b3385774882b08a2f0cf7bd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= Date: Wed, 26 Apr 2023 09:26:43 +0200 Subject: Windows: Tolerate GetShortPathNameW failure This function is used by NMake Makefile generator, but when shortening path fails, it previously returned an empty string. `ERROR_ACCESS_DENIED` is returned for paths within `C:\Program Files\WindowsApps`, which is a special folder with limited access rights. It looks like this is [by design](https://superuser.com/a/1730061/213587). Fixes: #24853 --- Source/cmOutputConverter.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 40fed80..53cb21e 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -175,7 +175,12 @@ std::string cmOutputConverter::ConvertToOutputForExisting( } std::string tmp{}; - cmSystemTools::GetShortPath(remote, tmp); + cmsys::Status status = cmSystemTools::GetShortPath(remote, tmp); + if (!status) { + // Fallback for cases when Windows refuses to resolve the short path, + // like for C:\Program Files\WindowsApps\... + tmp = remote; + } shortPathCache[remote] = tmp; return tmp; }(); -- cgit v0.12