From 4fdfb5587f4d6f704336b57bae57cc0268f8768c Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 30 Dec 2000 12:47:48 +0000 Subject: [PATCH] Various fixes for wxFilename. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9023 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/filename.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 7fa61c0a55..28c761783c 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -75,12 +75,18 @@ void wxFileName::Assign( const wxString &path, bool dir_only, wxPathFormat forma seps = ":"; } - wxStringTokenizer tn( path, seps ); + wxStringTokenizer tn( path, seps, wxTOKEN_RET_EMPTY_ALL ); + bool first = TRUE; while (tn.HasMoreTokens()) { wxString token( tn.GetNextToken() ); - if (!token.IsEmpty()) + + // If the path starts with a slash, we need the first + // dir entry to be an empty for later reassembly. + + if (first || !token.IsEmpty()) m_dirs.Add( token ); + first = FALSE; } if (!dir_only) @@ -344,6 +350,7 @@ void wxFileName::SetFullName( const wxString name, wxPathFormat format ) format = GetFormat( format ); m_name = name; + m_ext = wxEmptyString; if (m_name == wxT(".")) return; if (m_name == wxT("..")) return; @@ -409,7 +416,6 @@ wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const else if (format == wxPATH_UNIX) { - ret = '/'; // FIXME: must be absolute for (size_t i = 0; i < m_dirs.GetCount(); i++) { ret += m_dirs[i]; @@ -446,7 +452,6 @@ wxString wxFileName::GetFullPath( wxPathFormat format ) const else if (format == wxPATH_UNIX) { - ret = '/'; // FIXME: must be absolute for (size_t i = 0; i < m_dirs.GetCount(); i++) { ret += m_dirs[i]; -- 2.45.2