From: Vadim Zeitlin Date: Thu, 11 Apr 2002 12:20:27 +0000 (+0000) Subject: fixed GetPath() trailing separator bug, rewrote GetFullPath() in terms of GetPath() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4175794e0361c78ad63984cd01e4378677803dbc fixed GetPath() trailing separator bug, rewrote GetFullPath() in terms of GetPath() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15092 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 477ff3f121..be964d3111 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -1171,46 +1171,38 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const for ( size_t i = 0; i < dirCount; i++ ) { - // TODO: What to do with ".." under VMS - switch (format) { case wxPATH_MAC: - { if (m_dirs[i] == wxT(".")) break; if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing fullpath += m_dirs[i]; - fullpath += wxT(':'); break; - } + + default: + wxFAIL_MSG( wxT("unexpected path format") ); + // still fall through + case wxPATH_DOS: - { - fullpath += m_dirs[i]; - fullpath += wxT('\\'); - break; - } case wxPATH_UNIX: - { fullpath += m_dirs[i]; - fullpath += wxT('/'); break; - } + case wxPATH_VMS: - { + // TODO: What to do with ".." under VMS if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing fullpath += m_dirs[i]; - if (i == dirCount-1) - fullpath += wxT(']'); - else - fullpath += wxT('.'); break; - } - default: - { - wxFAIL_MSG( wxT("error") ); - } } + + if ( i != dirCount - 1 ) + fullpath += GetPathSeparator(format); + } + + if ( format == wxPATH_VMS ) + { + fullpath += wxT(']'); } } @@ -1224,91 +1216,11 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const wxString wxFileName::GetFullPath( wxPathFormat format ) const { - format = GetFormat(format); - - // first put the volume - wxString fullpath = wxGetVolumeString(m_volume, format); - - // the leading character - if ( format == wxPATH_MAC ) - { - if ( m_relative ) - fullpath += wxFILE_SEP_PATH_MAC; - } - else if ( format == wxPATH_DOS ) - { - if ( !m_relative ) - fullpath += wxFILE_SEP_PATH_DOS; - } - else if ( format == wxPATH_UNIX ) - { - if ( !m_relative ) - { - // normally the absolute file names starts with a slash with one - // exception: file names like "~/foo.bar" don't have it - if ( m_dirs.IsEmpty() || m_dirs[0u] != _T('~') ) - { - fullpath += wxFILE_SEP_PATH_UNIX; - } - } - } - - // then concatenate all the path components using the path separator - size_t dirCount = m_dirs.GetCount(); - if ( dirCount ) - { - if ( format == wxPATH_VMS ) - { - fullpath += wxT('['); - } - - - for ( size_t i = 0; i < dirCount; i++ ) - { - // TODO: What to do with ".." under VMS - - switch (format) - { - case wxPATH_MAC: - { - if (m_dirs[i] == wxT(".")) - break; - if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing - fullpath += m_dirs[i]; - fullpath += wxT(':'); - break; - } - case wxPATH_DOS: - { - fullpath += m_dirs[i]; - fullpath += wxT('\\'); - break; - } - case wxPATH_UNIX: - { - fullpath += m_dirs[i]; - fullpath += wxT('/'); - break; - } - case wxPATH_VMS: - { - if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing - fullpath += m_dirs[i]; - if (i == dirCount-1) - fullpath += wxT(']'); - else - fullpath += wxT('.'); - break; - } - default: - { - wxFAIL_MSG( wxT("error") ); - } - } - } - } + // we already have a function to get the path + wxString fullpath = GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR, + format); - // finally add the file name and extension + // now just add the file name and extension to it fullpath += GetFullName(); return fullpath;