From 67c34f64d4e2c2746f4a657ac7697a1d90fea383 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Apr 2002 22:42:35 +0000 Subject: [PATCH] fix for splitting the UNC paths git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15007 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/filename.cpp | 50 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 486f75b109..baaf7e0f33 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -239,6 +239,31 @@ static void ConvertWxToFileTime(FILETIME *ft, const wxDateTime& dt) #endif // __WIN32__ +// return a string with the volume par +static wxString wxGetVolumeString(const wxString& volume, wxPathFormat format) +{ + wxString path; + + if ( !volume.empty() ) + { + // Special Windows UNC paths hack, part 2: undo what we did in + // SplitPath() and make an UNC path if we have a drive which is not a + // single letter (hopefully the network shares can't be one letter only + // although I didn't find any authoritative docs on this) + if ( format == wxPATH_DOS && volume.length() > 1 ) + { + path << wxFILE_SEP_PATH_DOS << wxFILE_SEP_PATH_DOS << volume; + } + else if ( format == wxPATH_DOS || format == wxPATH_VMS ) + { + path << volume << wxFileName::GetVolumeSeparator(format); + } + // else ignore + } + + return path; +} + // ============================================================================ // implementation // ============================================================================ @@ -1192,27 +1217,8 @@ wxString wxFileName::GetFullPath( wxPathFormat format ) const { format = GetFormat(format); - wxString fullpath; - // first put the volume - if ( !m_volume.empty() ) - { - { - // Special Windows UNC paths hack, part 2: undo what we did in - // SplitPath() and make an UNC path if we have a drive which is not a - // single letter (hopefully the network shares can't be one letter only - // although I didn't find any authoritative docs on this) - if ( format == wxPATH_DOS && m_volume.length() > 1 ) - { - fullpath << wxFILE_SEP_PATH_DOS << wxFILE_SEP_PATH_DOS << m_volume; - } - else if ( format == wxPATH_DOS || format == wxPATH_VMS ) - { - fullpath << m_volume << GetVolumeSeparator(format); - } - // else ignore - } - } + wxString fullpath = wxGetVolumeString(m_volume, format); // the leading character if ( format == wxPATH_MAC ) @@ -1620,9 +1626,9 @@ void wxFileName::SplitPath(const wxString& fullpath, wxString volume; SplitPath(fullpath, &volume, path, name, ext, format); - if ( path && !volume.empty() ) + if ( path ) { - path->Prepend(volume + GetVolumeSeparator(format)); + path->Prepend(wxGetVolumeString(volume, format)); } }