use wxString in wxFileSystem::FindFileInPath()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46544 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -118,7 +118,7 @@ Converts filename into URL.
|
|||||||
|
|
||||||
\membersection{wxFileSystem::FindFileInPath}\label{wxfilesystemfindfileinpath}
|
\membersection{wxFileSystem::FindFileInPath}\label{wxfilesystemfindfileinpath}
|
||||||
|
|
||||||
\func{bool}{FindFileInPath}{\param{wxString }{*str}, \param{const wxChar }{*path}, \param{const wxChar }{*file}}
|
\func{bool}{FindFileInPath}{\param{wxString }{*str}, \param{const wxString\& }{path}, \param{const wxString\& }{file}}
|
||||||
|
|
||||||
Looks for the file with the given name \arg{file} in a colon or semi-colon
|
Looks for the file with the given name \arg{file} in a colon or semi-colon
|
||||||
(depending on the current platform) separated list of directories in
|
(depending on the current platform) separated list of directories in
|
||||||
|
@@ -205,7 +205,8 @@ public:
|
|||||||
wxString FindNext();
|
wxString FindNext();
|
||||||
|
|
||||||
// find a file in a list of directories, returns false if not found
|
// find a file in a list of directories, returns false if not found
|
||||||
bool FindFileInPath(wxString *pStr, const wxChar *path, const wxChar *file);
|
bool FindFileInPath(wxString *pStr,
|
||||||
|
const wxString& path, const wxString& file);
|
||||||
|
|
||||||
// Adds FS handler.
|
// Adds FS handler.
|
||||||
// In fact, this class is only front-end to the FS handlers :-)
|
// In fact, this class is only front-end to the FS handlers :-)
|
||||||
|
@@ -518,16 +518,19 @@ wxString wxFileSystem::FindNext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileSystem::FindFileInPath(wxString *pStr,
|
bool wxFileSystem::FindFileInPath(wxString *pStr,
|
||||||
const wxChar *path,
|
const wxString& path,
|
||||||
const wxChar *basename)
|
const wxString& basename)
|
||||||
{
|
{
|
||||||
// we assume that it's not empty
|
// we assume that it's not empty
|
||||||
wxCHECK_MSG( !wxIsEmpty(basename), false,
|
wxCHECK_MSG( !basename.empty(), false,
|
||||||
_T("empty file name in wxFileSystem::FindFileInPath"));
|
_T("empty file name in wxFileSystem::FindFileInPath"));
|
||||||
|
|
||||||
|
wxString name;
|
||||||
// skip path separator in the beginning of the file name if present
|
// skip path separator in the beginning of the file name if present
|
||||||
if ( wxIsPathSeparator(*basename) )
|
if ( wxIsPathSeparator(basename[0u]) )
|
||||||
basename++;
|
name = basename.substr(1);
|
||||||
|
else
|
||||||
|
name = basename;
|
||||||
|
|
||||||
wxStringTokenizer tokenizer(path, wxPATH_SEP);
|
wxStringTokenizer tokenizer(path, wxPATH_SEP);
|
||||||
while ( tokenizer.HasMoreTokens() )
|
while ( tokenizer.HasMoreTokens() )
|
||||||
@@ -535,7 +538,7 @@ bool wxFileSystem::FindFileInPath(wxString *pStr,
|
|||||||
wxString strFile = tokenizer.GetNextToken();
|
wxString strFile = tokenizer.GetNextToken();
|
||||||
if ( !wxEndsWithPathSeparator(strFile) )
|
if ( !wxEndsWithPathSeparator(strFile) )
|
||||||
strFile += wxFILE_SEP_PATH;
|
strFile += wxFILE_SEP_PATH;
|
||||||
strFile += basename;
|
strFile += name;
|
||||||
|
|
||||||
wxFSFile *file = OpenFile(strFile);
|
wxFSFile *file = OpenFile(strFile);
|
||||||
if ( file )
|
if ( file )
|
||||||
|
Reference in New Issue
Block a user