]>
Commit | Line | Data |
---|---|---|
1ee445c7 | 1 | /////////////////////////////////////////////////////////////////////////////// |
96e2aec5 VZ |
2 | // Name: wx/stdpaths.h |
3 | // Purpose: declaration of wxStandardPaths class | |
1ee445c7 VZ |
4 | // Author: Vadim Zeitlin |
5 | // Modified by: | |
6 | // Created: 2004-10-17 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
0b75a1e0 VZ |
12 | #ifndef _WX_STDPATHS_H_ |
13 | #define _WX_STDPATHS_H_ | |
1ee445c7 | 14 | |
07158944 VZ |
15 | #include "wx/defs.h" |
16 | ||
6cb5e50b | 17 | #include "wx/string.h" |
f45bffb6 | 18 | #include "wx/filefn.h" |
6cb5e50b | 19 | |
25f49256 VZ |
20 | class WXDLLIMPEXP_FWD_BASE wxStandardPaths; |
21 | ||
1ee445c7 | 22 | // ---------------------------------------------------------------------------- |
96e2aec5 | 23 | // wxStandardPaths returns the standard locations in the file system |
1ee445c7 VZ |
24 | // ---------------------------------------------------------------------------- |
25 | ||
6ae3ead6 VS |
26 | // NB: This is always compiled in, wxUSE_STDPATHS=0 only disables native |
27 | // wxStandardPaths class, but a minimal version is always available | |
6cb5e50b | 28 | class WXDLLIMPEXP_BASE wxStandardPathsBase |
1ee445c7 VZ |
29 | { |
30 | public: | |
f1b08e84 | 31 | // possible resources categories |
3af9f2de VZ |
32 | enum ResourceCat |
33 | { | |
34 | // no special category | |
35 | ResourceCat_None, | |
36 | ||
37 | // message catalog resources | |
38 | ResourceCat_Messages, | |
39 | ||
40 | // end of enum marker | |
41 | ResourceCat_Max | |
42 | }; | |
43 | ||
2b147f2e VZ |
44 | // what should we use to construct paths unique to this application: |
45 | // (AppInfo_AppName and AppInfo_VendorName can be combined together) | |
46 | enum | |
47 | { | |
48 | AppInfo_None = 0, // nothing | |
49 | AppInfo_AppName = 1, // the application name | |
50 | AppInfo_VendorName = 2 // the vendor name | |
51 | }; | |
52 | ||
3af9f2de | 53 | |
6cb5e50b | 54 | // return the global standard paths object |
25f49256 | 55 | static wxStandardPaths& Get(); |
48713afd | 56 | |
ac7ad70d RR |
57 | // return the path (directory+filename) of the running executable or |
58 | // wxEmptyString if it couldn't be determined. | |
59 | // The path is returned as an absolute path whenever possible. | |
60 | // Default implementation only try to use wxApp->argv[0]. | |
61 | virtual wxString GetExecutablePath() const; | |
48713afd | 62 | |
1ee445c7 | 63 | // return the directory with system config files: |
6cb5e50b VZ |
64 | // /etc under Unix, c:\Documents and Settings\All Users\Application Data |
65 | // under Windows, /Library/Preferences for Mac | |
66 | virtual wxString GetConfigDir() const = 0; | |
1ee445c7 VZ |
67 | |
68 | // return the directory for the user config files: | |
69 | // $HOME under Unix, c:\Documents and Settings\username under Windows, | |
70 | // ~/Library/Preferences under Mac | |
71 | // | |
72 | // only use this if you have a single file to put there, otherwise | |
73 | // GetUserDataDir() is more appropriate | |
6cb5e50b | 74 | virtual wxString GetUserConfigDir() const = 0; |
1ee445c7 VZ |
75 | |
76 | // return the location of the applications global, i.e. not user-specific, | |
77 | // data files | |
78 | // | |
48713afd VZ |
79 | // prefix/share/appname under Unix, c:\Program Files\appname under Windows, |
80 | // appname.app/Contents/SharedSupport app bundle directory under Mac | |
6cb5e50b | 81 | virtual wxString GetDataDir() const = 0; |
1ee445c7 VZ |
82 | |
83 | // return the location for application data files which are host-specific | |
84 | // | |
85 | // same as GetDataDir() except under Unix where it is /etc/appname | |
6cb5e50b | 86 | virtual wxString GetLocalDataDir() const; |
1ee445c7 VZ |
87 | |
88 | // return the directory for the user-dependent application data files | |
89 | // | |
90 | // $HOME/.appname under Unix, | |
91 | // c:\Documents and Settings\username\Application Data\appname under Windows | |
48713afd | 92 | // and ~/Library/Application Support/appname under Mac |
6cb5e50b | 93 | virtual wxString GetUserDataDir() const = 0; |
1ee445c7 VZ |
94 | |
95 | // return the directory for user data files which shouldn't be shared with | |
96 | // the other machines | |
97 | // | |
98 | // same as GetUserDataDir() for all platforms except Windows where it is | |
99 | // the "Local Settings\Application Data\appname" directory | |
6cb5e50b | 100 | virtual wxString GetUserLocalDataDir() const; |
1ee445c7 VZ |
101 | |
102 | // return the directory where the loadable modules (plugins) live | |
103 | // | |
48713afd | 104 | // prefix/lib/appname under Unix, program directory under Windows and |
1ee445c7 | 105 | // Contents/Plugins app bundle subdirectory under Mac |
6cb5e50b VZ |
106 | virtual wxString GetPluginsDir() const = 0; |
107 | ||
3af9f2de VZ |
108 | // get resources directory: resources are auxiliary files used by the |
109 | // application and include things like image and sound files | |
110 | // | |
111 | // same as GetDataDir() for all platforms except Mac where it returns | |
112 | // Contents/Resources subdirectory of the app bundle | |
113 | virtual wxString GetResourcesDir() const { return GetDataDir(); } | |
114 | ||
115 | // get localized resources directory containing the resource files of the | |
116 | // specified category for the given language | |
117 | // | |
118 | // in general this is just GetResourcesDir()/lang under Windows and Unix | |
119 | // and GetResourcesDir()/lang.lproj under Mac but is something quite | |
120 | // different under Unix for message catalog category (namely the standard | |
121 | // prefix/share/locale/lang/LC_MESSAGES) | |
122 | virtual wxString | |
e0b3b9d0 | 123 | GetLocalizedResourcesDir(const wxString& lang, |
8c943368 VZ |
124 | ResourceCat WXUNUSED(category) |
125 | = ResourceCat_None) const | |
3af9f2de VZ |
126 | { |
127 | return GetResourcesDir() + wxFILE_SEP_PATH + lang; | |
128 | } | |
129 | ||
17af82fb VZ |
130 | // return the "Documents" directory for the current user |
131 | // | |
9c498e84 | 132 | // C:\Documents and Settings\username\My Documents under Windows, |
17af82fb VZ |
133 | // $HOME under Unix and ~/Documents under Mac |
134 | virtual wxString GetDocumentsDir() const; | |
135 | ||
d8efd219 VZ |
136 | // return the directory for the documents files used by this application: |
137 | // it's a subdirectory of GetDocumentsDir() constructed using the | |
138 | // application name/vendor if it exists or just GetDocumentsDir() otherwise | |
139 | virtual wxString GetAppDocumentsDir() const; | |
140 | ||
ecf9559d JS |
141 | // return the temporary directory for the current user |
142 | virtual wxString GetTempDir() const; | |
143 | ||
6cb5e50b VZ |
144 | |
145 | // virtual dtor for the base class | |
146 | virtual ~wxStandardPathsBase(); | |
ce336c6d | 147 | |
2b147f2e VZ |
148 | // Information used by AppendAppInfo |
149 | void UseAppInfo(int info) | |
150 | { | |
151 | m_usedAppInfo = info; | |
152 | } | |
153 | ||
154 | bool UsesAppInfo(int info) const { return (m_usedAppInfo & info) != 0; } | |
155 | ||
156 | ||
ce336c6d | 157 | protected: |
38aae140 VZ |
158 | // Ctor is protected as this is a base class which should never be created |
159 | // directly. | |
160 | wxStandardPathsBase(); | |
161 | ||
d8efd219 VZ |
162 | // append the path component, with a leading path separator if a |
163 | // path separator or dot (.) is not already at the end of dir | |
2b147f2e VZ |
164 | static wxString AppendPathComponent(const wxString& dir, const wxString& component); |
165 | ||
166 | // append application information determined by m_usedAppInfo to dir | |
167 | wxString AppendAppInfo(const wxString& dir) const; | |
168 | ||
169 | ||
170 | // combination of AppInfo_XXX flags used by AppendAppInfo() | |
171 | int m_usedAppInfo; | |
1ee445c7 VZ |
172 | }; |
173 | ||
6ae3ead6 | 174 | #if wxUSE_STDPATHS |
d98a58c5 | 175 | #if defined(__WINDOWS__) |
6ae3ead6 VS |
176 | #include "wx/msw/stdpaths.h" |
177 | #define wxHAS_NATIVE_STDPATHS | |
178 | // We want CoreFoundation paths on both CarbonLib and Darwin (for all ports) | |
179 | #elif defined(__WXMAC__) || defined(__DARWIN__) | |
ef0e9220 | 180 | #include "wx/osx/core/stdpaths.h" |
6ae3ead6 VS |
181 | #define wxHAS_NATIVE_STDPATHS |
182 | #elif defined(__OS2__) | |
183 | #include "wx/os2/stdpaths.h" | |
184 | #define wxHAS_NATIVE_STDPATHS | |
185 | #elif defined(__UNIX__) | |
186 | #include "wx/unix/stdpaths.h" | |
187 | #define wxHAS_NATIVE_STDPATHS | |
6ae3ead6 VS |
188 | #endif |
189 | #endif | |
46a28273 MW |
190 | |
191 | // ---------------------------------------------------------------------------- | |
d6f42b1b | 192 | // Minimal generic implementation |
46a28273 MW |
193 | // ---------------------------------------------------------------------------- |
194 | ||
6ae3ead6 VS |
195 | // NB: Note that this minimal implementation is compiled in even if |
196 | // wxUSE_STDPATHS=0, so that our code can still use wxStandardPaths. | |
197 | ||
198 | #ifndef wxHAS_NATIVE_STDPATHS | |
46a28273 MW |
199 | class WXDLLIMPEXP_BASE wxStandardPaths : public wxStandardPathsBase |
200 | { | |
201 | public: | |
202 | void SetInstallPrefix(const wxString& prefix) { m_prefix = prefix; } | |
203 | wxString GetInstallPrefix() const { return m_prefix; } | |
ac7ad70d RR |
204 | |
205 | virtual wxString GetExecutablePath() const { return m_prefix; } | |
46a28273 MW |
206 | virtual wxString GetConfigDir() const { return m_prefix; } |
207 | virtual wxString GetUserConfigDir() const { return m_prefix; } | |
208 | virtual wxString GetDataDir() const { return m_prefix; } | |
209 | virtual wxString GetLocalDataDir() const { return m_prefix; } | |
210 | virtual wxString GetUserDataDir() const { return m_prefix; } | |
211 | virtual wxString GetPluginsDir() const { return m_prefix; } | |
17af82fb | 212 | virtual wxString GetDocumentsDir() const { return m_prefix; } |
46a28273 | 213 | |
38aae140 VZ |
214 | protected: |
215 | // Ctor is protected because wxStandardPaths::Get() should always be used | |
216 | // to access the global wxStandardPaths object of the correct type instead | |
217 | // of creating one of a possibly wrong type yourself. | |
218 | wxStandardPaths() { } | |
219 | ||
46a28273 MW |
220 | private: |
221 | wxString m_prefix; | |
222 | }; | |
6ae3ead6 | 223 | #endif // !wxHAS_NATIVE_STDPATHS |
07158944 | 224 | |
0b75a1e0 | 225 | #endif // _WX_STDPATHS_H_ |
1ee445c7 | 226 |