24#include <wx/tokenzr.h>
29 #define PATH_SEPS wxT( ";\r\n" )
31 #define PATH_SEPS wxT( ":;\r\n" )
37 wxStringTokenizer tokenizer( aPathString,
PATH_SEPS, wxTOKEN_STRTOK );
39 while( tokenizer.HasMoreTokens() )
41 wxString
path = tokenizer.GetNextToken();
46 return aResult->GetCount();
51static wxString
base_dir(
const wxString& aRelativePath,
const wxString& aBaseDir )
53 wxFileName fn = aRelativePath;
55 if( !fn.IsAbsolute() && !!aBaseDir )
57 wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(),
58 wxT(
"Must pass absolute path in aBaseDir" ) );
59 fn.MakeRelativeTo( aBaseDir );
62 return fn.GetFullPath();
67 const wxString& aFullFilename,
const wxString& aBaseDir )
69 wxFileName fn = aFullFilename;
70 wxString filename = aFullFilename;
72 unsigned pathlen = fn.GetPath().Len();
75 for(
unsigned kk = 0; kk < GetCount(); kk++ )
80 if( fn.MakeRelativeTo(
base_dir( (*
this)[kk], aBaseDir ) ) )
82 if( fn.GetPathWithSep().StartsWith( wxT(
"..") ) )
85 if( pathlen > fn.GetPath().Len() )
87 filename = fn.GetPathWithSep() + fn.GetFullName();
88 pathlen = fn.GetPath().Len();
99 bool isCS = wxFileName::IsCaseSensitive();
102 Split( &paths, aPaths );
104 for(
unsigned i=0; i<paths.GetCount(); ++i )
106 wxString
path = paths[i];
108 if( Index(
path, isCS ) != wxNOT_FOUND )
118 bool isCS = wxFileName::IsCaseSensitive();
121 Split( &paths, aPaths );
124 if(
unsigned( aIndex ) >= GetCount() )
126 for(
unsigned i=0; i<paths.GetCount(); ++i )
128 wxString
path = paths[i];
130 if( wxFileName::IsDirReadable(
path )
131 && Index(
path, isCS ) == wxNOT_FOUND )
141 for(
unsigned i=0; i<paths.GetCount(); ++i )
143 wxString
path = paths[i];
145 if( wxFileName::IsDirReadable(
path )
146 && Index(
path, isCS ) == wxNOT_FOUND )
148 Insert(
path, aIndex );
164 unsigned pcount = GetCount();
170 if( (*
this)[0] == wxGetCwd() )
175 path = (*this)[ipath];
180 for( ; ipath < pcount; ipath++ )
182 if( (*
this)[ipath].Contains( aSubPathToSearch ) )
184 path = (*this)[ipath];
200void SEARCH_STACK::Show(
const wxString& aPrefix )
const
204 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.