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.
This commit is contained in:
Vadim Zeitlin 2022-04-14 22:52:39 +01:00
parent 35d08e6a87
commit d6c3344c6f

View File

@ -2232,8 +2232,20 @@ wxString wxFileName::GetLongPath() const
return pathOut; 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. // We need to call FindFirstFile on each component in turn.
WIN32_FIND_DATA findFileData; WIN32_FIND_DATA findFileData;