]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: stdpaths.h | |
e54c96f1 | 3 | // Purpose: interface of wxStandardPaths |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
8 | /** | |
9 | @class wxStandardPaths | |
7c913512 | 10 | |
23324ae1 FM |
11 | wxStandardPaths returns the standard locations in the file system and should be |
12 | used by applications to find their data files in a portable way. | |
7c913512 | 13 | |
75618d57 VZ |
14 | Note that you must not create objects of class wxStandardPaths directly, |
15 | but use the global standard paths object returned by wxStandardPaths::Get() | |
16 | (which can be of a type derived from wxStandardPaths and not of exactly | |
17 | this type) and call the methods you need on it. The object returned by | |
18 | Get() may be customized by overriding wxAppTraits::GetStandardPaths() | |
19 | methods. | |
20 | ||
23324ae1 FM |
21 | In the description of the methods below, the example return values are given |
22 | for the Unix, Windows and Mac OS X systems, however please note that these are | |
23 | just the examples and the actual values may differ. For example, under Windows: | |
4f83b9fc | 24 | the system administrator may change the standard directories locations, e.g. |
4701dc09 FM |
25 | the Windows directory may be named @c "W:\Win2003" instead of |
26 | the default @c "C:\Windows". | |
7c913512 | 27 | |
4f83b9fc | 28 | Notice that in the examples below the string @c appinfo may be either just |
9508a056 VZ |
29 | the application name (as returned by wxApp::GetAppName()) or a combination |
30 | of the vendor name (wxApp::GetVendorName()) and the application name, with | |
6da1d056 VZ |
31 | a path separator between them. By default, only the application name is |
32 | used, use UseAppInfo() to change this. | |
9508a056 VZ |
33 | |
34 | The other placeholders should be self-explanatory: the string @c username | |
35 | should be replaced with the value the name of the currently logged in user. | |
36 | and @c prefix is only used under Unix and is @c /usr/local by default but | |
37 | may be changed using wxStandardPaths::SetInstallPrefix(). | |
7c913512 | 38 | |
4701dc09 FM |
39 | The directories returned by the methods of this class may or may not exist. |
40 | If they don't exist, it's up to the caller to create them, wxStandardPaths doesn't | |
23324ae1 | 41 | do it. |
7c913512 | 42 | |
23324ae1 FM |
43 | Finally note that these functions only work with standardly packaged |
44 | applications. I.e. under Unix you should follow the standard installation | |
45 | conventions and under Mac you should create your application bundle according | |
46 | to the Apple guidelines. Again, this class doesn't help you to do it. | |
7c913512 | 47 | |
23324ae1 FM |
48 | This class is MT-safe: its methods may be called concurrently from different |
49 | threads without additional locking. | |
7c913512 | 50 | |
23324ae1 FM |
51 | @library{wxbase} |
52 | @category{file} | |
7c913512 | 53 | |
e54c96f1 | 54 | @see wxFileConfig |
4701dc09 | 55 | */ |
7c913512 | 56 | class wxStandardPaths |
23324ae1 FM |
57 | { |
58 | public: | |
f1b08e84 VZ |
59 | /// Possible values for category parameter of GetLocalizedResourcesDir(). |
60 | enum ResourceCat | |
61 | { | |
62 | /// No special category, this is the default. | |
63 | ResourceCat_None, | |
64 | ||
65 | /// Message catalog resources category. | |
66 | ResourceCat_Messages | |
67 | }; | |
68 | ||
69 | ||
4cd15b49 VZ |
70 | /** |
71 | MSW-specific function undoing the effect of IgnoreAppSubDir() calls. | |
72 | ||
73 | After a call to this function the program directory will be exactly the | |
74 | directory containing the main application binary, i.e. it undoes the | |
75 | effect of any previous IgnoreAppSubDir() calls including the ones done | |
76 | indirectly by IgnoreAppBuildSubDirs() called from the class | |
77 | constructor. | |
78 | ||
79 | @since 2.9.1 | |
80 | */ | |
81 | void DontIgnoreAppSubDir(); | |
82 | ||
23324ae1 FM |
83 | /** |
84 | Returns reference to the unique global standard paths object. | |
85 | */ | |
25f49256 | 86 | static wxStandardPaths& Get(); |
23324ae1 | 87 | |
d8efd219 VZ |
88 | /** |
89 | Return the directory for the document files used by this application. | |
90 | ||
91 | If the application-specific directory doesn't exist, this function | |
92 | returns GetDocumentsDir(). | |
93 | ||
94 | Example return values: | |
4f83b9fc VZ |
95 | - Unix: @c ~/appinfo |
96 | - Windows: @c "C:\Documents and Settings\username\My Documents\appinfo" | |
97 | - Mac: @c ~/Documents/appinfo | |
d8efd219 VZ |
98 | |
99 | @since 2.9.0 | |
100 | ||
101 | @see GetAppDocumentsDir() | |
102 | */ | |
103 | virtual wxString GetAppDocumentsDir() const; | |
104 | ||
23324ae1 FM |
105 | /** |
106 | Return the directory containing the system config files. | |
23324ae1 | 107 | Example return values: |
4701dc09 FM |
108 | - Unix: @c /etc |
109 | - Windows: @c "C:\Documents and Settings\All Users\Application Data" | |
110 | - Mac: @c /Library/Preferences | |
3c4f71cc | 111 | |
4cc4bfaf | 112 | @see wxFileConfig |
23324ae1 | 113 | */ |
adaaa686 | 114 | virtual wxString GetConfigDir() const; |
23324ae1 FM |
115 | |
116 | /** | |
0824e369 | 117 | Return the location of the applications global, i.e.\ not user-specific, |
23324ae1 | 118 | data files. |
306a5d95 | 119 | |
23324ae1 | 120 | Example return values: |
4f83b9fc | 121 | - Unix: @c prefix/share/appinfo |
4701dc09 | 122 | - Windows: the directory where the executable file is located |
4f83b9fc | 123 | - Mac: @c appinfo.app/Contents/SharedSupport bundle subdirectory |
3c4f71cc | 124 | |
306a5d95 VZ |
125 | Under Unix (only) it is possible to override the default value returned |
126 | from this function by setting the value of @c WX_APPNAME_DATA_DIR | |
127 | environment variable to the directory to use (where @c APPNAME is the | |
128 | upper-cased value of wxApp::GetAppName()). This is useful in order to | |
129 | be able to run applications using this function without installing them | |
130 | as you can simply set this environment variable to the source directory | |
131 | location to allow the application to find its files there. | |
132 | ||
4cc4bfaf | 133 | @see GetLocalDataDir() |
23324ae1 | 134 | */ |
adaaa686 | 135 | virtual wxString GetDataDir() const; |
23324ae1 FM |
136 | |
137 | /** | |
138 | Return the directory containing the current user's documents. | |
d8efd219 | 139 | |
23324ae1 | 140 | Example return values: |
4701dc09 FM |
141 | - Unix: @c ~ (the home directory) |
142 | - Windows: @c "C:\Documents and Settings\username\My Documents" | |
143 | - Mac: @c ~/Documents | |
3c4f71cc | 144 | |
1e24c2af | 145 | @since 2.7.0 |
d8efd219 VZ |
146 | |
147 | @see GetAppDocumentsDir() | |
23324ae1 | 148 | */ |
adaaa686 | 149 | virtual wxString GetDocumentsDir() const; |
23324ae1 FM |
150 | |
151 | /** | |
152 | Return the directory and the filename for the current executable. | |
23324ae1 | 153 | Example return values: |
4701dc09 FM |
154 | - Unix: @c /usr/local/bin/exename |
155 | - Windows: @c "C:\Programs\AppFolder\exename.exe" | |
76dd097a | 156 | - Mac: @c /Applications/exename.app/Contents/MacOS/exename |
23324ae1 | 157 | */ |
adaaa686 | 158 | virtual wxString GetExecutablePath() const; |
23324ae1 FM |
159 | |
160 | /** | |
0824e369 | 161 | Return the program installation prefix, e.g.\ @c /usr, @c /opt or @c /home/zeitlin. |
4701dc09 | 162 | |
89666a22 | 163 | If the prefix had been previously by SetInstallPrefix(), returns that |
4701dc09 FM |
164 | value, otherwise tries to determine it automatically (Linux only right now) |
165 | and finally returns the default @c /usr/local value if it failed. | |
166 | ||
52cd5180 VZ |
167 | @note This function is only available under Unix platforms (but not limited |
168 | to wxGTK mentioned below). | |
169 | ||
170 | @onlyfor{wxos2,wxgtk} | |
23324ae1 | 171 | */ |
328f5751 | 172 | wxString GetInstallPrefix() const; |
23324ae1 FM |
173 | |
174 | /** | |
175 | Return the location for application data files which are host-specific and | |
176 | can't, or shouldn't, be shared with the other machines. | |
4701dc09 | 177 | |
4f83b9fc | 178 | This is the same as GetDataDir() except under Unix where it returns @c /etc/appinfo. |
23324ae1 | 179 | */ |
adaaa686 | 180 | virtual wxString GetLocalDataDir() const; |
23324ae1 FM |
181 | |
182 | /** | |
183 | Return the localized resources directory containing the resource files of the | |
184 | specified category for the given language. | |
4701dc09 FM |
185 | |
186 | In general this is just the same as @a lang subdirectory of GetResourcesDir() | |
187 | (or @c lang.lproj under Mac OS X) but is something quite different for | |
188 | message catalog category under Unix where it returns the standard | |
e3d8295c | 189 | @c prefix/share/locale/lang/LC_MESSAGES directory. |
3c4f71cc | 190 | |
1e24c2af | 191 | @since 2.7.0 |
23324ae1 | 192 | */ |
f1b08e84 VZ |
193 | virtual wxString |
194 | GetLocalizedResourcesDir(const wxString& lang, | |
195 | ResourceCat category = ResourceCat_None) const; | |
23324ae1 FM |
196 | |
197 | /** | |
198 | Return the directory where the loadable modules (plugins) live. | |
23324ae1 | 199 | Example return values: |
4f83b9fc | 200 | - Unix: @c prefix/lib/appinfo |
4701dc09 | 201 | - Windows: the directory of the executable file |
4f83b9fc | 202 | - Mac: @c appinfo.app/Contents/PlugIns bundle subdirectory |
3c4f71cc | 203 | |
4cc4bfaf | 204 | @see wxDynamicLibrary |
23324ae1 | 205 | */ |
adaaa686 | 206 | virtual wxString GetPluginsDir() const; |
23324ae1 FM |
207 | |
208 | /** | |
4701dc09 FM |
209 | Return the directory where the application resource files are located. |
210 | ||
211 | The resources are the auxiliary data files needed for the application to run | |
212 | and include, for example, image and sound files it might use. | |
213 | ||
214 | This function is the same as GetDataDir() for all platforms except Mac OS X. | |
23324ae1 | 215 | Example return values: |
4f83b9fc | 216 | - Unix: @c prefix/share/appinfo |
4701dc09 | 217 | - Windows: the directory where the executable file is located |
4f83b9fc | 218 | - Mac: @c appinfo.app/Contents/Resources bundle subdirectory |
3c4f71cc | 219 | |
1e24c2af | 220 | @since 2.7.0 |
3c4f71cc | 221 | |
4cc4bfaf | 222 | @see GetLocalizedResourcesDir() |
23324ae1 | 223 | */ |
adaaa686 | 224 | virtual wxString GetResourcesDir() const; |
23324ae1 FM |
225 | |
226 | /** | |
4701dc09 FM |
227 | Return the directory for storing temporary files. |
228 | To create unique temporary files, it is best to use wxFileName::CreateTempFileName | |
229 | for correct behaviour when multiple processes are attempting to create temporary files. | |
3c4f71cc | 230 | |
1e24c2af | 231 | @since 2.7.2 |
23324ae1 | 232 | */ |
adaaa686 | 233 | virtual wxString GetTempDir() const; |
23324ae1 FM |
234 | |
235 | /** | |
236 | Return the directory for the user config files: | |
4701dc09 FM |
237 | - Unix: @c ~ (the home directory) |
238 | - Windows: @c "C:\Documents and Settings\username\Application Data" | |
239 | - Mac: @c ~/Library/Preferences | |
240 | ||
23324ae1 | 241 | Only use this method if you have a single configuration file to put in this |
f9afe2fe VZ |
242 | directory, otherwise GetUserDataDir() is more appropriate as the latter |
243 | adds @c appinfo to the path, unlike this function. | |
23324ae1 | 244 | */ |
adaaa686 | 245 | virtual wxString GetUserConfigDir() const; |
23324ae1 FM |
246 | |
247 | /** | |
248 | Return the directory for the user-dependent application data files: | |
4f83b9fc VZ |
249 | - Unix: @c ~/.appinfo |
250 | - Windows: @c "C:\Documents and Settings\username\Application Data\appinfo" | |
251 | - Mac: @c "~/Library/Application Support/appinfo" | |
23324ae1 | 252 | */ |
adaaa686 | 253 | virtual wxString GetUserDataDir() const; |
23324ae1 FM |
254 | |
255 | /** | |
256 | Return the directory for user data files which shouldn't be shared with | |
257 | the other machines. | |
4701dc09 | 258 | |
ad51d1c8 | 259 | This is the same as GetUserDataDir() for all platforms except Windows where it returns |
4f83b9fc | 260 | @c "C:\Documents and Settings\username\Local Settings\Application Data\appinfo" |
23324ae1 | 261 | */ |
adaaa686 | 262 | virtual wxString GetUserLocalDataDir() const; |
23324ae1 | 263 | |
4cd15b49 VZ |
264 | /** |
265 | MSW-specific function to customize application directory detection. | |
266 | ||
267 | This class supposes that data, plugins &c files are located under the | |
268 | program directory which is the directory containing the application | |
269 | binary itself. But sometimes this binary may be in a subdirectory of | |
270 | the main program directory, e.g. this happens in at least the following | |
271 | common cases: | |
272 | - The program is in "bin" subdirectory of the installation directory. | |
273 | - The program is in "debug" subdirectory of the directory containing | |
274 | sources and data files during development | |
275 | ||
276 | By calling this function you instruct the class to remove the last | |
277 | component of the path if it matches its argument. Notice that it may be | |
278 | called more than once, e.g. you can call both IgnoreAppSubDir("bin") and | |
279 | IgnoreAppSubDir("debug") to take care of both production and development | |
280 | cases above but that each call will only remove the last path component. | |
281 | Finally note that the argument can contain wild cards so you can also | |
282 | call IgnoreAppSubDir("vc*msw*") to ignore all build directories at once | |
283 | when using wxWidgets-inspired output directories names. | |
284 | ||
285 | @since 2.9.1 | |
286 | ||
287 | @see IgnoreAppBuildSubDirs() | |
288 | ||
289 | @param subdirPattern | |
290 | The subdirectory containing the application binary which should be | |
291 | ignored when determining the top application directory. The pattern | |
292 | is case-insensitive and may contain wild card characters @c '?' and | |
293 | @c '*'. | |
294 | */ | |
295 | void IgnoreAppSubDir(const wxString& subdirPattern); | |
296 | ||
297 | /** | |
298 | MSW-specific function to ignore all common build directories. | |
299 | ||
300 | This function calls IgnoreAppSubDir() with all common values for build | |
301 | directory, e.g. @c "debug" and @c "release". | |
302 | ||
303 | It is called by the class constructor and so the build directories are | |
304 | always ignored by default. You may use DontIgnoreAppSubDir() to avoid | |
305 | ignoring them if this is inappropriate for your application. | |
306 | ||
307 | @since 2.9.1 | |
308 | */ | |
309 | void IgnoreAppBuildSubDirs(); | |
310 | ||
94aff795 VZ |
311 | /** |
312 | Returns location of Windows shell special folder. | |
313 | ||
314 | This function is, by definition, MSW-specific. It can be used to access | |
315 | pre-defined shell directories not covered by the existing methods of | |
316 | this class, e.g.: | |
317 | @code | |
318 | #ifdef __WXMSW__ | |
319 | // get the location of files waiting to be burned on a CD | |
320 | wxString cdburnArea = | |
321 | wxStandardPaths::MSWGetShellDir(CSIDL_CDBURN_AREA); | |
322 | #endif // __WXMSW__ | |
323 | @endcode | |
324 | ||
325 | @param csidl | |
326 | ||
327 | @since 2.9.1 | |
328 | */ | |
329 | static wxString MSWGetShellDir(int csidl); | |
330 | ||
23324ae1 | 331 | /** |
23324ae1 | 332 | Lets wxStandardPaths know about the real program installation prefix on a Unix |
4701dc09 FM |
333 | system. By default, the value returned by GetInstallPrefix() is used. |
334 | ||
23324ae1 FM |
335 | Although under Linux systems the program prefix may usually be determined |
336 | automatically, portable programs should call this function. Usually the prefix | |
337 | is set during program configuration if using GNU autotools and so it is enough | |
338 | to pass its value defined in @c config.h to this function. | |
4701dc09 | 339 | |
52cd5180 VZ |
340 | @note This function is only available under Unix platforms (but not limited |
341 | to wxGTK mentioned below). | |
342 | ||
343 | @onlyfor{wxos2,wxgtk} | |
23324ae1 FM |
344 | */ |
345 | void SetInstallPrefix(const wxString& prefix); | |
346 | ||
347 | /** | |
348 | Controls what application information is used when constructing paths that | |
349 | should be unique to this program, such as the application data directory, the | |
350 | plugins directory on Unix, etc. | |
4701dc09 | 351 | |
4f83b9fc VZ |
352 | Valid values for @a info are: |
353 | - @c AppInfo_None: don't use neither application nor vendor name in | |
354 | the paths. | |
355 | - @c AppInfo_AppName: use the application name in the paths. | |
356 | - @c AppInfo_VendorName: use the vendor name in the paths, usually | |
357 | used combined with AppInfo_AppName, i.e. as @code AppInfo_AppName | | |
358 | AppInfo_VendorName @endcode | |
4701dc09 | 359 | |
6da1d056 | 360 | By default, only the application name is used. |
9508a056 VZ |
361 | |
362 | @since 2.9.0 | |
23324ae1 FM |
363 | */ |
364 | void UseAppInfo(int info); | |
38aae140 VZ |
365 | |
366 | protected: | |
367 | /** | |
368 | Protected default constructor. | |
369 | ||
370 | This constructor is protected in order to prevent creation of objects | |
371 | of this class as Get() should be used instead to access the unique | |
372 | global wxStandardPaths object of the correct type. | |
373 | */ | |
374 | wxStandardPaths(); | |
23324ae1 | 375 | }; |
e54c96f1 | 376 |