git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49059
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void wxGenericFileCtrl::DoGetFilenames( wxArrayString& filenames, const bool fullPath ) const
{
void wxGenericFileCtrl::DoGetFilenames( wxArrayString& filenames, const bool fullPath ) const
{
const wxString dir = m_list->GetDir();
const wxString dir = m_list->GetDir();
- const wxString value = m_text->GetValue();
+ const wxString value = m_text->GetValue();
- if ( fullPath )
- filenames.Add( dir + value );
- else
- filenames.Add( value );
+ wxFileName fn(value);
+ if ( fn.IsRelative() )
+ fn.MakeAbsolute(dir);
+
+ filenames.push_back(fullPath ? fn.GetFullPath() : fn.GetFullName());
- if ( m_list->GetSelectedItemCount() == 0 )
- {
+ const int numSel = m_list->GetSelectedItemCount();
+ if ( !numSel )
- filenames.Alloc( m_list->GetSelectedItemCount() );
+ filenames.reserve(numSel);
wxListItem item;
item.m_mask = wxLIST_MASK_TEXT;
wxListItem item;
item.m_mask = wxLIST_MASK_TEXT;
-
- item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
- while ( item.m_itemId != -1 )
+ item.m_itemId = -1;
+ for ( ;; )
- m_list->GetItem( item );
+ item.m_itemId = m_list->GetNextItem(item.m_itemId, wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
- if ( fullPath )
- filenames.Add( dir + item.m_text );
- else
- filenames.Add( item.m_text );
+ if ( item.m_itemId == -1 )
+ break;
+
+ m_list->GetItem(item);
- item.m_itemId = m_list->GetNextItem( item.m_itemId,
- wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+ const wxFileName fn(dir, item.m_text);
+ filenames.push_back(fullPath ? fn.GetFullPath() : fn.GetFullName());