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(),
62 wxT(
"Must pass absolute path in aBaseDir" ) );
63 fn.MakeRelativeTo( aBaseDir );
66 return fn.GetFullPath();
71 const wxString& aFullFilename,
const wxString& aBaseDir )
73 wxFileName fn = aFullFilename;
74 wxString filename = aFullFilename;
76 unsigned pathlen = fn.GetPath().Len();
79 for(
unsigned kk = 0; kk < GetCount(); kk++ )
84 if( fn.MakeRelativeTo(
base_dir( (*
this)[kk], aBaseDir ) ) )
86 if( fn.GetPathWithSep().StartsWith( wxT(
"..") ) )
89 if( pathlen > fn.GetPath().Len() )
91 filename = fn.GetPathWithSep() + fn.GetFullName();
92 pathlen = fn.GetPath().Len();
103 bool isCS = wxFileName::IsCaseSensitive();
106 Split( &paths, aPaths );
108 for(
unsigned i=0; i<paths.GetCount(); ++i )
110 wxString
path = paths[i];
112 if( Index(
path, isCS ) != wxNOT_FOUND )
122 bool isCS = wxFileName::IsCaseSensitive();
125 Split( &paths, aPaths );
128 if(
unsigned( aIndex ) >= GetCount() )
130 for(
unsigned i=0; i<paths.GetCount(); ++i )
132 wxString
path = paths[i];
134 if( wxFileName::IsDirReadable(
path )
135 && Index(
path, isCS ) == wxNOT_FOUND )
145 for(
unsigned i=0; i<paths.GetCount(); ++i )
147 wxString
path = paths[i];
149 if( wxFileName::IsDirReadable(
path )
150 && Index(
path, isCS ) == wxNOT_FOUND )
152 Insert(
path, aIndex );
168 unsigned pcount = GetCount();
174 if( (*
this)[0] == wxGetCwd() )
179 path = (*this)[ipath];
184 for( ; ipath < pcount; ipath++ )
186 if( (*
this)[ipath].Contains( aSubPathToSearch ) )
188 path = (*this)[ipath];
204void SEARCH_STACK::Show(
const wxString& aPrefix )
const
208 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.