mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
cmSystemTools: Drop GetRealPathResolvingWindowsSubst
It was created by commit 83630d4918
(cmSystemTools: Revert GetRealPath
implementation on Windows, 2018-05-29, v3.11.3~3^2) to preserve support
on Windows for one call site. Now that `GetRealPath` works again on
Windows, we can use that instead.
Issue: #18033
This commit is contained in:
@@ -1101,43 +1101,6 @@ std::string cmSystemTools::GetComspec()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string cmSystemTools::GetRealPathResolvingWindowsSubst(
|
|
||||||
const std::string& path, std::string* errorMessage)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
// uv_fs_realpath uses Windows Vista API so fallback to kwsys if not found
|
|
||||||
std::string resolved_path;
|
|
||||||
uv_fs_t req;
|
|
||||||
int err = uv_fs_realpath(nullptr, &req, path.c_str(), nullptr);
|
|
||||||
if (!err) {
|
|
||||||
resolved_path = std::string((char*)req.ptr);
|
|
||||||
cmSystemTools::ConvertToUnixSlashes(resolved_path);
|
|
||||||
// Normalize to upper-case drive letter as GetActualCaseForPath does.
|
|
||||||
if (resolved_path.size() > 1 && resolved_path[1] == ':') {
|
|
||||||
resolved_path[0] = toupper(resolved_path[0]);
|
|
||||||
}
|
|
||||||
} else if (err == UV_ENOSYS) {
|
|
||||||
resolved_path = cmsys::SystemTools::GetRealPath(path, errorMessage);
|
|
||||||
} else if (errorMessage) {
|
|
||||||
LPSTR message = nullptr;
|
|
||||||
DWORD size = FormatMessageA(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&message,
|
|
||||||
0, nullptr);
|
|
||||||
*errorMessage = std::string(message, size);
|
|
||||||
LocalFree(message);
|
|
||||||
|
|
||||||
resolved_path = "";
|
|
||||||
} else {
|
|
||||||
resolved_path = path;
|
|
||||||
}
|
|
||||||
return resolved_path;
|
|
||||||
#else
|
|
||||||
return cmsys::SystemTools::GetRealPath(path, errorMessage);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string cmSystemTools::GetRealPath(const std::string& path,
|
std::string cmSystemTools::GetRealPath(const std::string& path,
|
||||||
std::string* errorMessage)
|
std::string* errorMessage)
|
||||||
{
|
{
|
||||||
|
@@ -605,11 +605,7 @@ public:
|
|||||||
static std::string GetComspec();
|
static std::string GetComspec();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Get the real path for a given path, removing all symlinks.
|
/** Get the real path for a given path, removing all symlinks. */
|
||||||
This variant of GetRealPath also works on Windows but will
|
|
||||||
resolve subst drives too. */
|
|
||||||
static std::string GetRealPathResolvingWindowsSubst(
|
|
||||||
const std::string& path, std::string* errorMessage = nullptr);
|
|
||||||
static std::string GetRealPath(const std::string& path,
|
static std::string GetRealPath(const std::string& path,
|
||||||
std::string* errorMessage = nullptr);
|
std::string* errorMessage = nullptr);
|
||||||
|
|
||||||
|
@@ -62,8 +62,7 @@ std::string cmTimestamp::FileModificationTime(const char* path,
|
|||||||
const std::string& formatString,
|
const std::string& formatString,
|
||||||
bool utcFlag) const
|
bool utcFlag) const
|
||||||
{
|
{
|
||||||
std::string real_path =
|
std::string real_path = cmSystemTools::GetRealPath(path);
|
||||||
cmSystemTools::GetRealPathResolvingWindowsSubst(path);
|
|
||||||
|
|
||||||
if (!cmsys::SystemTools::FileExists(real_path)) {
|
if (!cmsys::SystemTools::FileExists(real_path)) {
|
||||||
return std::string();
|
return std::string();
|
||||||
|
Reference in New Issue
Block a user