]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxPathList}}\label{wxpathlist} |
2 | ||
3 | The path list is a convenient way of storing a number of directories, and | |
4 | when presented with a filename without a directory, searching for an existing file | |
34e2d943 | 5 | in those directories. |
a660d684 | 6 | |
34e2d943 RR |
7 | Be sure to look also at \helpref{wxStandardPaths}{wxstandardpaths} if you only |
8 | want to search files in some standard paths. | |
a660d684 KB |
9 | |
10 | \wxheading{Derived from} | |
11 | ||
8daf3c36 | 12 | \helpref{wxArrayString}{wxarraystring} |
a660d684 | 13 | |
954b8ae6 JS |
14 | \wxheading{Include files} |
15 | ||
16 | <wx/filefn.h> | |
17 | ||
a7af285d VZ |
18 | \wxheading{Library} |
19 | ||
20 | \helpref{wxBase}{librarieslist} | |
21 | ||
a660d684 KB |
22 | \wxheading{See also} |
23 | ||
31a8bf3f | 24 | \helpref{wxArrayString}{wxarraystring}, \helpref{wxStandardPaths}{wxstandardpaths}, \helpref{wxFileName}{wxfilename} |
a660d684 KB |
25 | |
26 | \latexignore{\rtfignore{\wxheading{Members}}} | |
27 | ||
4d01e350 | 28 | |
dcbd177f | 29 | \membersection{wxPathList::wxPathList}\label{wxpathlistctor} |
a660d684 KB |
30 | |
31 | \func{}{wxPathList}{\void} | |
32 | ||
8daf3c36 VZ |
33 | Empty constructor. |
34 | ||
35 | \func{}{wxPathList}{\param{const wxArrayString\& }{arr}} | |
36 | ||
37 | Constructs the object calling the \helpref{Add}{wxpathlistadd} function. | |
a660d684 | 38 | |
4d01e350 | 39 | |
dcbd177f | 40 | \membersection{wxPathList::AddEnvList}\label{wxpathlistaddenvlist} |
a660d684 KB |
41 | |
42 | \func{void}{AddEnvList}{\param{const wxString\& }{env\_variable}} | |
43 | ||
44 | Finds the value of the given environment variable, and adds all paths | |
34e2d943 | 45 | to the path list. Useful for finding files in the {\tt PATH} variable, for |
a660d684 KB |
46 | example. |
47 | ||
4d01e350 | 48 | |
dcbd177f | 49 | \membersection{wxPathList::Add}\label{wxpathlistadd} |
a660d684 | 50 | |
34e2d943 | 51 | \func{bool}{Add}{\param{const wxString\& }{path}} |
a660d684 | 52 | |
8daf3c36 VZ |
53 | \func{void}{Add}{\param{const wxArrayString\& }{arr}} |
54 | ||
31a8bf3f | 55 | The first form adds the given directory to the path list, if the path is not already in the list. |
34e2d943 RR |
56 | If the path cannot be normalized for some reason, it returns \false. |
57 | ||
8daf3c36 | 58 | The second form just calls the first form on all elements of the given array. |
4d01e350 | 59 | |
31a8bf3f RR |
60 | The {\it path} is always considered a directory but no existence checks will be done on it |
61 | (because if it doesn't exist, it could be created later and thus result a valid path when | |
62 | \helpref{FindValidPath}{wxpathlistfindvalidpath} is called). | |
63 | ||
64 | {\bf Note:} if the given path is relative, it won't be made absolute before adding it | |
65 | (this is why \helpref{FindValidPath}{wxpathlistfindvalidpath} may return relative paths). | |
66 | ||
a660d684 | 67 | |
dcbd177f | 68 | \membersection{wxPathList::EnsureFileAccessible}\label{wxpathlistensurefileaccessible} |
a660d684 | 69 | |
34e2d943 RR |
70 | \func{bool}{EnsureFileAccessible}{\param{const wxString\& }{filename}} |
71 | ||
4ba9f845 VZ |
72 | Given a full filename (with path), calls \helpref{Add}{wxpathlistadd} with the path |
73 | of the file. | |
a660d684 | 74 | |
4d01e350 | 75 | |
dcbd177f | 76 | \membersection{wxPathList::FindAbsoluteValidPath}\label{wxpathlistfindabsolutepath} |
a660d684 | 77 | |
8daf3c36 | 78 | \constfunc{wxString}{FindAbsoluteValidPath}{\param{const wxString\& }{file}} |
a660d684 | 79 | |
34e2d943 RR |
80 | Like \helpref{FindValidPath}{wxpathlistfindvalidpath} but this function always |
81 | returns an absolute path (eventually prepending the current working directory | |
82 | to the value returned \helpref{FindValidPath}{wxpathlistfindvalidpath}) or an | |
83 | empty string. | |
4d01e350 | 84 | |
a660d684 | 85 | |
dcbd177f | 86 | \membersection{wxPathList::FindValidPath}\label{wxpathlistfindvalidpath} |
a660d684 | 87 | |
8daf3c36 | 88 | \constfunc{wxString}{FindValidPath}{\param{const wxString\& }{file}} |
a660d684 | 89 | |
34e2d943 RR |
90 | Searches the given file in all paths stored in this class. |
91 | The first path which concatenated to the given string points to an existing | |
92 | file (see \helpref{wxFileExists}{wxfileexists}) is returned. | |
31a8bf3f | 93 | |
34e2d943 | 94 | If the file wasn't found in any of the stored paths, an empty string is returned. |
4d01e350 | 95 | |
31a8bf3f RR |
96 | The given string must be a file name, eventually with a path prefix (if the path |
97 | prefix is absolute, only its name will be searched); i.e. it must not end with | |
98 | a directory separator (see \helpref{wxFileName::GetPathSeparator}{wxfilenamegetpathseparator}) | |
99 | otherwise an assertion will fail. | |
b67a86d5 | 100 | |
34e2d943 RR |
101 | The returned path may be relative to the current working directory. |
102 | Note in fact that wxPathList can be used to store both relative and absolute paths so that | |
103 | if you \helpref{Add()}{wxpathlistadd}ed relative paths, then the current working directory | |
104 | (see \helpref{wxGetCwd}{wxgetcwd} and \helpref{wxSetWorkingDirectory}{wxsetworkingdirectory}) | |
105 | may affect the value returned by this function! | |
106 |