Fix handling of single letter shares in UNC paths in wxFileName
This comes at the price of breaking compatibility and returning "\\share" rather than just "share" from wxFileName::GetVolume() for the UNC paths. This breakage seems justified because it is required in order to allow application code to distinguish between paths "x:\foo" and "\\x\foo", which was previously impossible as GetVolume() returned just "x" in both cases. Document this change, adjust the existing checks for the new GetVolume() semantics and add a new test which passes now, but didn't pass before. Closes #19255. This commit is best viewed ignoring whitespace-only changes.
This commit is contained in:
@@ -82,9 +82,9 @@ static struct TestFileNameInfo
|
||||
{ "c:\\foo.bar", "c", "\\", "foo", "bar", true, wxPATH_DOS },
|
||||
{ "c:\\Windows\\command.com", "c", "\\Windows", "command", "com", true, wxPATH_DOS },
|
||||
{ "\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}\\",
|
||||
"Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}", "\\", "", "", true, wxPATH_DOS },
|
||||
"\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}", "\\", "", "", true, wxPATH_DOS },
|
||||
{ "\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}\\Program Files\\setup.exe",
|
||||
"Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}", "\\Program Files", "setup", "exe", true, wxPATH_DOS },
|
||||
"\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}", "\\Program Files", "setup", "exe", true, wxPATH_DOS },
|
||||
|
||||
#if 0
|
||||
// NB: when using the wxFileName::GetLongPath() function on these two
|
||||
@@ -544,11 +544,11 @@ TEST_CASE("wxFileName::ShortLongPath", "[filename]")
|
||||
TEST_CASE("wxFileName::UNC", "[filename]")
|
||||
{
|
||||
wxFileName fn("//share/path/name.ext", wxPATH_DOS);
|
||||
CHECK( fn.GetVolume() == "share" );
|
||||
CHECK( fn.GetVolume() == "\\\\share" );
|
||||
CHECK( fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) == "\\path" );
|
||||
|
||||
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" );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
@@ -557,6 +557,11 @@ TEST_CASE("wxFileName::UNC", "[filename]")
|
||||
// beginning.
|
||||
fn.Assign("d:\\\\root\\directory\\file");
|
||||
CHECK( fn.GetFullPath() == "d:\\root\\directory\\file" );
|
||||
|
||||
// Check that single letter UNC paths don't turn into drive letters, as
|
||||
// they used to do.
|
||||
fn.Assign("\\\\x\\dir\\file");
|
||||
CHECK( fn.GetFullPath() == "\\\\x\\dir\\file" );
|
||||
#endif // __WINDOWS__
|
||||
}
|
||||
|
||||
@@ -564,13 +569,13 @@ TEST_CASE("wxFileName::VolumeUniqueName", "[filename]")
|
||||
{
|
||||
wxFileName fn("\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}\\",
|
||||
wxPATH_DOS);
|
||||
CHECK( fn.GetVolume() == "Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}" );
|
||||
CHECK( fn.GetVolume() == "\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}" );
|
||||
CHECK( fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) == "\\" );
|
||||
CHECK( fn.GetFullPath(wxPATH_DOS) == "\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}\\" );
|
||||
|
||||
fn.Assign("\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}\\"
|
||||
"Program Files\\setup.exe", wxPATH_DOS);
|
||||
CHECK( fn.GetVolume() == "Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}" );
|
||||
CHECK( fn.GetVolume() == "\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}" );
|
||||
CHECK( fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) == "\\Program Files" );
|
||||
CHECK( fn.GetFullPath(wxPATH_DOS) == "\\\\?\\Volume{8089d7d7-d0ac-11db-9dd0-806d6172696f}\\Program Files\\setup.exe" );
|
||||
}
|
||||
|
Reference in New Issue
Block a user