wxpathlistthe 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. be sure to look also at wxstandardpaths if you only want to search files in some standard paths. derived from include files <wx/filefn.h> see also wxarraystring, wxstandardpaths, wxfilename members
wxpathlist::wxpathlist
wxpathlist::wxpathlistwxpathlist() empty constructor. wxpathlist(const wxarraystring& arr) constructs the object calling the add function.
wxpathlist::addenvlistvoid 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.
wxpathlist::addbool 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. if the path cannot be normalized for some reason, it returns false. 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).
wxpathlist::ensurefileaccessiblebool ensurefileaccessible(const wxstring& filename) given a full filename (with path), calls add with the path of the file.
wxpathlist::findabsolutevalidpathwxstring findabsolutevalidpath(const wxstring& file) const like findvalidpath but this function always returns an absolute path (eventually prepending the current working directory to the value returned findvalidpath) or an empty string.
wxpathlist::findvalidpathwxstring findvalidpath(const wxstring& file) const searches the given file in all paths stored in this class. the first path which concatenated to the given string points to an existing file (see wxfileexists) is returned. if the file wasn't found in any of the stored paths, an empty string is returned. 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. the returned path may be relative to the current working directory. note in fact that wxpathlist can be used to store both relative and absolute paths so that if you add()ed relative paths, then the current working directory (see wxgetcwd and wxsetworkingdirectory) may affect the value returned by this function!
|