extern const wxULongLong wxInvalidSize = (unsigned)-1;
#endif // wxUSE_LONGLONG
+namespace
+{
// ----------------------------------------------------------------------------
// private classes
return path;
}
+// return true if the character is a DOS path separator i.e. either a slash or
+// a backslash
+inline bool IsDOSPathSep(wxUniChar ch)
+{
+ return ch == wxFILE_SEP_PATH_DOS || ch == wxFILE_SEP_PATH_UNIX;
+}
+
// return true if the format used is the DOS/Windows one and the string looks
// like a UNC path
static bool IsUNCPath(const wxString& path, wxPathFormat format)
{
return format == wxPATH_DOS &&
path.length() >= 4 && // "\\a" can't be a UNC path
- path[0u] == wxFILE_SEP_PATH_DOS &&
- path[1u] == wxFILE_SEP_PATH_DOS &&
- path[2u] != wxFILE_SEP_PATH_DOS;
+ IsDOSPathSep(path[0u]) &&
+ IsDOSPathSep(path[1u]) &&
+ !IsDOSPathSep(path[2u]);
}
+} // anonymous namespace
+
// ============================================================================
// implementation
// ============================================================================
#ifdef __WINDOWS__
CPPUNIT_TEST( TestShortLongPath );
#endif // __WINDOWS__
+ CPPUNIT_TEST( TestUNC );
CPPUNIT_TEST_SUITE_END();
void TestConstruction();
#ifdef __WINDOWS__
void TestShortLongPath();
#endif // __WINDOWS__
+ void TestUNC();
DECLARE_NO_COPY_CLASS(FileNameTestCase)
};
}
#endif // __WINDOWS__
+
+void FileNameTestCase::TestUNC()
+{
+ wxFileName fn("//share/path/name.ext", wxPATH_DOS);
+ CPPUNIT_ASSERT_EQUAL( "share", fn.GetVolume() );
+ CPPUNIT_ASSERT_EQUAL( "/path", fn.GetPath() );
+
+ fn.Assign("\\\\share2\\path2\\name.ext", wxPATH_DOS);
+ CPPUNIT_ASSERT_EQUAL( "share2", fn.GetVolume() );
+ CPPUNIT_ASSERT_EQUAL( "/path2", fn.GetPath() );
+}
+