Fix handling multiple leading backslashes in wxFileName under MSW
Extend the existing workaround to work not only with explicitly wxPATH_DOS paths, but with paths implicitly using the DOS format due to it being the default format for the current platform. Closes #19261.
This commit is contained in:
@@ -290,7 +290,7 @@ inline bool IsDOSPathSep(wxUniChar ch)
|
|||||||
// like a UNC path
|
// like a UNC path
|
||||||
static bool IsUNCPath(const wxString& path, wxPathFormat format)
|
static bool IsUNCPath(const wxString& path, wxPathFormat format)
|
||||||
{
|
{
|
||||||
return format == wxPATH_DOS &&
|
return wxFileName::GetFormat(format) == wxPATH_DOS &&
|
||||||
path.length() >= 4 && // "\\a" can't be a UNC path
|
path.length() >= 4 && // "\\a" can't be a UNC path
|
||||||
IsDOSPathSep(path[0u]) &&
|
IsDOSPathSep(path[0u]) &&
|
||||||
IsDOSPathSep(path[1u]) &&
|
IsDOSPathSep(path[1u]) &&
|
||||||
|
@@ -550,6 +550,14 @@ TEST_CASE("wxFileName::UNC", "[filename]")
|
|||||||
fn.Assign("\\\\share2\\path2\\name.ext", wxPATH_DOS);
|
fn.Assign("\\\\share2\\path2\\name.ext", wxPATH_DOS);
|
||||||
CHECK( fn.GetVolume() == "share2" );
|
CHECK( fn.GetVolume() == "share2" );
|
||||||
CHECK( fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) == "\\path2" );
|
CHECK( fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) == "\\path2" );
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
// Check that doubled backslashes in the beginning of the path are not
|
||||||
|
// misinterpreted as UNC volume when we have a drive letter in the
|
||||||
|
// beginning.
|
||||||
|
fn.Assign("d:\\\\root\\directory\\file");
|
||||||
|
CHECK( fn.GetFullPath() == "d:\\root\\directory\\file" );
|
||||||
|
#endif // __WINDOWS__
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("wxFileName::VolumeUniqueName", "[filename]")
|
TEST_CASE("wxFileName::VolumeUniqueName", "[filename]")
|
||||||
|
Reference in New Issue
Block a user