From 593177c566d3471189571641fb9db8efa27ed551 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 19 Jun 2007 17:39:27 +0000 Subject: [PATCH] use wxString in wxFileSystem::FindFileInPath() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46544 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/filesys.tex | 2 +- include/wx/filesys.h | 3 ++- src/common/filesys.cpp | 15 +++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/latex/wx/filesys.tex b/docs/latex/wx/filesys.tex index ddca00a1a2..091c522174 100644 --- a/docs/latex/wx/filesys.tex +++ b/docs/latex/wx/filesys.tex @@ -118,7 +118,7 @@ Converts filename into URL. \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 (depending on the current platform) separated list of directories in diff --git a/include/wx/filesys.h b/include/wx/filesys.h index 686c64ac0c..02ae931a03 100644 --- a/include/wx/filesys.h +++ b/include/wx/filesys.h @@ -205,7 +205,8 @@ public: wxString FindNext(); // 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. // In fact, this class is only front-end to the FS handlers :-) diff --git a/src/common/filesys.cpp b/src/common/filesys.cpp index 8488c57702..7e6044e4c2 100644 --- a/src/common/filesys.cpp +++ b/src/common/filesys.cpp @@ -518,16 +518,19 @@ wxString wxFileSystem::FindNext() } bool wxFileSystem::FindFileInPath(wxString *pStr, - const wxChar *path, - const wxChar *basename) + const wxString& path, + const wxString& basename) { // we assume that it's not empty - wxCHECK_MSG( !wxIsEmpty(basename), false, + wxCHECK_MSG( !basename.empty(), false, _T("empty file name in wxFileSystem::FindFileInPath")); + wxString name; // skip path separator in the beginning of the file name if present - if ( wxIsPathSeparator(*basename) ) - basename++; + if ( wxIsPathSeparator(basename[0u]) ) + name = basename.substr(1); + else + name = basename; wxStringTokenizer tokenizer(path, wxPATH_SEP); while ( tokenizer.HasMoreTokens() ) @@ -535,7 +538,7 @@ bool wxFileSystem::FindFileInPath(wxString *pStr, wxString strFile = tokenizer.GetNextToken(); if ( !wxEndsWithPathSeparator(strFile) ) strFile += wxFILE_SEP_PATH; - strFile += basename; + strFile += name; wxFSFile *file = OpenFile(strFile); if ( file ) -- 2.45.2