X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8c9d760210f5f077dfebabef942652068bad82e7..f239a20092359e3c914adb79bd39f3f5d2b2e06f:/src/common/fs_mem.cpp?ds=sidebyside diff --git a/src/common/fs_mem.cpp b/src/common/fs_mem.cpp index 41cc094434..e306437de4 100644 --- a/src/common/fs_mem.cpp +++ b/src/common/fs_mem.cpp @@ -70,7 +70,7 @@ private: #endif // wxUSE_DATETIME } - DECLARE_NO_COPY_CLASS(wxMemoryFSFile) + wxDECLARE_NO_COPY_CLASS(wxMemoryFSFile); }; #if wxUSE_BASE @@ -122,19 +122,51 @@ wxFSFile * wxMemoryFSHandlerBase::OpenFile(wxFileSystem& WXUNUSED(fs), ); } -wxString wxMemoryFSHandlerBase::FindFirst(const wxString& WXUNUSED(spec), - int WXUNUSED(flags)) +wxString wxMemoryFSHandlerBase::FindFirst(const wxString& url, int flags) { - wxFAIL_MSG(wxT("wxMemoryFSHandlerBase::FindFirst not implemented")); + if ( (flags & wxDIR) && !(flags & wxFILE) ) + { + // we only store files, not directories, so we don't risk finding + // anything + return wxString(); + } + + const wxString spec = GetRightLocation(url); + if ( spec.find_first_of("?*") == wxString::npos ) + { + // simple case: there are no wildcard characters so we can return + // either 0 or 1 results and we can find the potential match quickly + return m_Hash.count(spec) ? url : wxString(); + } + //else: deal with wildcards in FindNext() + + m_findArgument = spec; + m_findIter = m_Hash.begin(); - return wxEmptyString; + return FindNext(); } wxString wxMemoryFSHandlerBase::FindNext() { - wxFAIL_MSG(wxT("wxMemoryFSHandlerBase::FindNext not implemented")); + // m_findArgument is used to indicate that search is in progress, we reset + // it to empty string after iterating over all elements + while ( !m_findArgument.empty() ) + { + // test for the match before (possibly) clearing m_findArgument below + 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; + + if ( ++m_findIter == m_Hash.end() ) + m_findArgument.clear(); + + if ( found ) + return "memory:" + current->first; + } - return wxEmptyString; + return wxString(); } bool wxMemoryFSHandlerBase::CheckDoesntExist(const wxString& filename) @@ -154,9 +186,13 @@ void wxMemoryFSHandlerBase::AddFileWithMimeType(const wxString& filename, const wxString& textdata, const wxString& mimetype) { - AddFileWithMimeType(filename, - (const void*) textdata.mb_str(), textdata.length(), - mimetype); + AddFileWithMimeType + ( + filename, + static_cast(textdata.To8BitData()), + wxStrlen(static_cast(textdata.To8BitData())), + mimetype + ); } @@ -217,7 +253,7 @@ wxMemoryFSHandler::AddFile(const wxString& filename, return; wxMemoryOutputStream mems; - if ( image.Ok() && image.SaveFile(mems, type) ) + if ( image.IsOk() && image.SaveFile(mems, type) ) { m_Hash[filename] = new wxMemoryFSFile (