]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
Recognize UNCs starting with forward slashes too in wxFileName.
[wxWidgets.git] / src / common / filename.cpp
index 9142e61c23053c8b3d986a89fbc9b2dd93b6b321..09b03c625187214cb7ba9a1758a570f3666515ed 100644 (file)
 extern const wxULongLong wxInvalidSize = (unsigned)-1;
 #endif // wxUSE_LONGLONG
 
+namespace
+{
 
 // ----------------------------------------------------------------------------
 // private classes
@@ -295,17 +297,26 @@ static wxString wxGetVolumeString(const wxString& volume, wxPathFormat format)
     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
 // ============================================================================
@@ -486,9 +497,11 @@ void wxFileName::Assign(const wxString& fullpathOrig,
 
     SplitPath(fullpath, &volume, &path, &nameDummy, &extDummy, format);
 
-    wxASSERT_MSG( nameDummy.empty() && extDummy.empty(),
+#ifndef __VMS
+   // This test makes no sense on an OpenVMS system.
+   wxASSERT_MSG( nameDummy.empty() && extDummy.empty(),
                   wxT("the path shouldn't contain file name nor extension") );
-
+#endif
     Assign(volume, path, name, ext, hasExt, format);
 }