added FindFileInPath() (part of an otherwise rejected patch)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40266 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "wx/module.h"
|
||||
#include "wx/mimetype.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -447,7 +448,37 @@ wxString wxFileSystem::FindNext()
|
||||
else return m_FindFileHandler -> FindNext();
|
||||
}
|
||||
|
||||
bool wxFileSystem::FindFileInPath(wxString *pStr,
|
||||
const wxChar *path,
|
||||
const wxChar *basename)
|
||||
{
|
||||
// we assume that it's not empty
|
||||
wxCHECK_MSG( !wxIsEmpty(basename), false,
|
||||
_T("empty file name in wxFileSystem::FindFileInPath"));
|
||||
|
||||
// skip path separator in the beginning of the file name if present
|
||||
if ( wxIsPathSeparator(*basename) )
|
||||
basename++;
|
||||
|
||||
wxStringTokenizer tokenizer(path, wxPATH_SEP);
|
||||
while ( tokenizer.HasMoreTokens() )
|
||||
{
|
||||
wxString strFile = tokenizer.GetNextToken();
|
||||
if ( !wxEndsWithPathSeparator(strFile) )
|
||||
strFile += wxFILE_SEP_PATH;
|
||||
strFile += basename;
|
||||
|
||||
wxFSFile *file = OpenFile(strFile);
|
||||
if ( file )
|
||||
{
|
||||
delete file;
|
||||
*pStr = strFile;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxFileSystem::AddHandler(wxFileSystemHandler *handler)
|
||||
{
|
||||
|
Reference in New Issue
Block a user