Applied #12438 IsUNCPath patch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@66915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2011-02-16 21:46:49 +00:00
parent 26fe8aa995
commit 62f833c4af

View File

@@ -284,15 +284,22 @@ static wxString wxGetVolumeString(const wxString& volume, wxPathFormat format)
return path; return path;
} }
// return true if the character is a DOS path separator i.e. either a slash or
// a backslash
inline bool IsDOSPathSep(wxChar 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 // return true if the format used is the DOS/Windows one and the string looks
// 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 format == wxPATH_DOS &&
path.length() >= 4 && // "\\a" can't be a UNC path path.length() >= 4 && // "\\a" can't be a UNC path
path[0u] == wxFILE_SEP_PATH_DOS && IsDOSPathSep(path[0u]) &&
path[1u] == wxFILE_SEP_PATH_DOS && IsDOSPathSep(path[1u]) &&
path[2u] != wxFILE_SEP_PATH_DOS; !IsDOSPathSep(path[2u]);
} }
// ============================================================================ // ============================================================================