The path list is a convenient way of storing a number of directories, and when presented with a filename without a directory, searching for an existing file in those directories. Storing the filename only in an application's files and using a locally-defined list of directories makes the application and its files more portable.
Use the wxFileName::SplitPath global function to extract the filename from the path.
Derived from
Include files
<wx/filefn.h>
See also
wxArrayString, wxStandardPaths, wxFileName
Members
wxPathList::wxPathList
wxPathList::AddEnvList
wxPathList::Add
wxPathList::EnsureFileAccessible
wxPathList::FindAbsoluteValidPath
wxPathList::FindValidPath
wxPathList()
Empty constructor.
wxPathList(const wxArrayString& arr)
Constructs the object calling the Add function.
void AddEnvList(const wxString& env_variable)
Finds the value of the given environment variable, and adds all paths to the path list. Useful for finding files in the PATH variable, for example.
void Add(const wxString& path)
void Add(const wxArrayString& arr)
The first form adds the given directory to the path list, if the path is not already in the list. The second form just calls the first form on all elements of the given array.
The path is always considered a directory but no existence checks will be done on it (because if it doesn't exist, it could be created later and thus result a valid path when FindValidPath is called).
Note: if the given path is relative, it won't be made absolute before adding it (this is why FindValidPath may return relative paths).
void EnsureFileAccessible(const wxString& filename)
Given a full filename (with path), ensures that files in the same path can be accessed using the pathlist. It does this by stripping the filename and adding the path to the list if not already there.
wxString FindAbsoluteValidPath(const wxString& file) const
Searches for a full (i.e. absolute) path for an existing file by appending file to successive members of the path list. If the file wasn't found, an empty string is returned.
wxString FindValidPath(const wxString& file) const
Searches for a path for an existing file by appending file to successive members of the path list. If the file wasn't found, an empty string is returned.
The returned path may be relative to the current working directory.
The given string must be a file name, eventually with a path prefix (if the path prefix is absolute, only its name will be searched); i.e. it must not end with a directory separator (see wxFileName::GetPathSeparator) otherwise an assertion will fail.