28#include <wx/tokenzr.h>
33 #define PATH_SEPS wxT( ";\r\n" )
35 #define PATH_SEPS wxT( ":;\r\n" )
41 wxStringTokenizer tokenizer( aPathString,
PATH_SEPS, wxTOKEN_STRTOK );
43 while( tokenizer.HasMoreTokens() )
45 wxString
path = tokenizer.GetNextToken();
50 return aResult->GetCount();
55static wxString
base_dir(
const wxString& aRelativePath,
const wxString& aBaseDir )
57 wxFileName fn = aRelativePath;
59 if( !fn.IsAbsolute() && !!aBaseDir )
61 wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(), wxT(
"Must pass absolute path in aBaseDir" ) );
62 fn.MakeRelativeTo( aBaseDir );
65 return fn.GetFullPath();
70 const wxString& aFullFilename,
const wxString& aBaseDir )
72 wxFileName fn = aFullFilename;
73 wxString filename = aFullFilename;
75 unsigned pathlen = fn.GetPath().Len();
78 for(
unsigned kk = 0; kk < GetCount(); kk++ )
83 if( fn.MakeRelativeTo(
base_dir( (*
this)[kk], aBaseDir ) ) )
85 if( fn.GetPathWithSep().StartsWith( wxT(
"..") ) )
88 if( pathlen > fn.GetPath().Len() )
90 filename = fn.GetPathWithSep() + fn.GetFullName();
91 pathlen = fn.GetPath().Len();
102 bool isCS = wxFileName::IsCaseSensitive();
105 Split( &paths, aPaths );
107 for(
unsigned i=0; i<paths.GetCount(); ++i )
109 wxString
path = paths[i];
111 if( Index(
path, isCS ) != wxNOT_FOUND )
121 bool isCS = wxFileName::IsCaseSensitive();
124 Split( &paths, aPaths );
127 if(
unsigned( aIndex ) >= GetCount() )
129 for(
unsigned i=0; i<paths.GetCount(); ++i )
131 wxString
path = paths[i];
133 if( wxFileName::IsDirReadable(
path )
134 && Index(
path, isCS ) == wxNOT_FOUND )
144 for(
unsigned i=0; i<paths.GetCount(); ++i )
146 wxString
path = paths[i];
148 if( wxFileName::IsDirReadable(
path )
149 && Index(
path, isCS ) == wxNOT_FOUND )
151 Insert(
path, aIndex );
167 unsigned pcount = GetCount();
173 if( (*
this)[0] == wxGetCwd() )
178 path = (*this)[ipath];
183 for( ; ipath < pcount; ipath++ )
185 if( (*
this)[ipath].Contains( aSubPathToSearch ) )
187 path = (*this)[ipath];
203void SEARCH_STACK::Show(
const wxString& aPrefix )
const
207 for(
unsigned i=0; i<GetCount(); ++i )
const wxString LastVisitedPath(const wxString &aSubPathToSearch=wxEmptyString)
A quirky function inherited from old code that seems to serve particular needs in the UI.
static int Split(wxArrayString *aResult, const wxString &aPathString)
Separate aPathString into individual paths.
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
void RemovePaths(const wxString &aPaths)
Remove the given path(s) from the library path list.
wxString FilenameWithRelativePathInSearchList(const wxString &aFullFilename, const wxString &aBaseDir)
Return the shortest possible path which can be use later to find a full path from this SEARCH_STACK.
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
static wxString base_dir(const wxString &aRelativePath, const wxString &aBaseDir)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxLogTrace helper definitions.