Add wxDir::GetNameWithSep() and use it to avoid consecutive slashes.

It is wrong to use dir.GetName()+"/" to obtain a slash-terminated directory
name as this results in (usually harmless but at best ugly) double slashes at
at the beginning of the string for the root directory. Add GetNameWithSep() to
obtain the correct result in all cases.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71355 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-05-04 20:35:31 +00:00
parent 50cbca27ad
commit c9f6f0a8cd
5 changed files with 54 additions and 4 deletions

View File

@@ -235,9 +235,13 @@ void DirTestCase::GetName()
CPPUNIT_ASSERT( d.Open(".") );
CPPUNIT_ASSERT( d.GetName().Last() != wxFILE_SEP_PATH );
CPPUNIT_ASSERT( d.GetNameWithSep().Last() == wxFILE_SEP_PATH );
CPPUNIT_ASSERT_EQUAL( d.GetName() + wxFILE_SEP_PATH,
d.GetNameWithSep() );
#ifdef __UNIX__
CPPUNIT_ASSERT( d.Open("/") );
CPPUNIT_ASSERT_EQUAL( "/", d.GetName() );
CPPUNIT_ASSERT_EQUAL( "/", d.GetNameWithSep() );
#endif
}