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