From d6c3344c6ff124bbf2e0cd054eb050157bae4776 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 14 Apr 2022 22:52:39 +0100 Subject: [PATCH] Don't try finding the long form of non-existent paths This is at best useless and at worst harmful, as shown by the bug fixed in the previous commit, so just don't do it if GetLongPathName() has already determined that the path doesn't exist. --- src/common/filename.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 3185e39cba..13629a51af 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -2232,8 +2232,20 @@ wxString wxFileName::GetLongPath() const return pathOut; } } + else // GetLongPathName() failed. + { + // The error returned for non-existent UNC paths is different, to make + // things more interesting. + const DWORD err = ::GetLastError(); + if ( err == ERROR_FILE_NOT_FOUND || err == ERROR_BAD_NETPATH ) + { + // No need to try to do anything else, we're not going to be able + // to find a long path form of a non-existent path anyhow. + return path; + } + } - // Some other error occured. + // File exists, but some other error occurred. // We need to call FindFirstFile on each component in turn. WIN32_FIND_DATA findFileData;