fix bugs in FindFirst() (it gets URL, not filename, on input) and FindNext() (which always forgot the last match) (fixes #10077)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
139ea30e15
commit
c8c86bd0ba
@ -122,7 +122,7 @@ wxFSFile * wxMemoryFSHandlerBase::OpenFile(wxFileSystem& WXUNUSED(fs),
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxMemoryFSHandlerBase::FindFirst(const wxString& spec, int flags)
|
wxString wxMemoryFSHandlerBase::FindFirst(const wxString& url, int flags)
|
||||||
{
|
{
|
||||||
if ( (flags & wxDIR) && !(flags & wxFILE) )
|
if ( (flags & wxDIR) && !(flags & wxFILE) )
|
||||||
{
|
{
|
||||||
@ -131,11 +131,12 @@ wxString wxMemoryFSHandlerBase::FindFirst(const wxString& spec, int flags)
|
|||||||
return wxString();
|
return wxString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxString spec = GetRightLocation(url);
|
||||||
if ( spec.find_first_of("?*") == wxString::npos )
|
if ( spec.find_first_of("?*") == wxString::npos )
|
||||||
{
|
{
|
||||||
// simple case: there are no wildcard characters so we can return
|
// simple case: there are no wildcard characters so we can return
|
||||||
// either 0 or 1 results and we can find the potential match quickly
|
// either 0 or 1 results and we can find the potential match quickly
|
||||||
return m_Hash.count(spec) ? spec : wxString();
|
return m_Hash.count(spec) ? url : wxString();
|
||||||
}
|
}
|
||||||
//else: deal with wildcards in FindNext()
|
//else: deal with wildcards in FindNext()
|
||||||
|
|
||||||
@ -151,15 +152,18 @@ wxString wxMemoryFSHandlerBase::FindNext()
|
|||||||
// it to empty string after iterating over all elements
|
// it to empty string after iterating over all elements
|
||||||
while ( !m_findArgument.empty() )
|
while ( !m_findArgument.empty() )
|
||||||
{
|
{
|
||||||
// advance m_findIter before checking the value at the current position
|
// test for the match before (possibly) clearing m_findArgument below
|
||||||
// as we need to do it anyhow, whether it matches or not
|
const bool found = m_findIter->first.Matches(m_findArgument);
|
||||||
|
|
||||||
|
// advance m_findIter first as we need to do it anyhow, whether it
|
||||||
|
// matches or not
|
||||||
const wxMemoryFSHash::const_iterator current = m_findIter;
|
const wxMemoryFSHash::const_iterator current = m_findIter;
|
||||||
|
|
||||||
if ( ++m_findIter == m_Hash.end() )
|
if ( ++m_findIter == m_Hash.end() )
|
||||||
m_findArgument.clear();
|
m_findArgument.clear();
|
||||||
|
|
||||||
if ( current->first.Matches(m_findArgument) )
|
if ( found )
|
||||||
return current->first;
|
return "memory:" + current->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxString();
|
return wxString();
|
||||||
|
Loading…
Reference in New Issue
Block a user