1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of wxStandardPaths class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STDPATHS_H_
13 #define _WX_STDPATHS_H_
17 #include "wx/string.h"
18 #include "wx/filefn.h"
20 // ----------------------------------------------------------------------------
21 // wxStandardPaths returns the standard locations in the file system
22 // ----------------------------------------------------------------------------
24 // NB: This is always compiled in, wxUSE_STDPATHS=0 only disables native
25 // wxStandardPaths class, but a minimal version is always available
26 class WXDLLIMPEXP_BASE wxStandardPathsBase
29 // possible resources categorires
32 // no special category
35 // message catalog resources
42 // what should we use to construct paths unique to this application:
43 // (AppInfo_AppName and AppInfo_VendorName can be combined together)
46 AppInfo_None
= 0, // nothing
47 AppInfo_AppName
= 1, // the application name
48 AppInfo_VendorName
= 2 // the vendor name
52 // return the global standard paths object
53 static wxStandardPathsBase
& Get();
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;
61 // return the directory with system config files:
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;
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
70 // only use this if you have a single file to put there, otherwise
71 // GetUserDataDir() is more appropriate
72 virtual wxString
GetUserConfigDir() const = 0;
74 // return the location of the applications global, i.e. not user-specific,
77 // prefix/share/appname under Unix, c:\Program Files\appname under Windows,
78 // appname.app/Contents/SharedSupport app bundle directory under Mac
79 virtual wxString
GetDataDir() const = 0;
81 // return the location for application data files which are host-specific
83 // same as GetDataDir() except under Unix where it is /etc/appname
84 virtual wxString
GetLocalDataDir() const;
86 // return the directory for the user-dependent application data files
88 // $HOME/.appname under Unix,
89 // c:\Documents and Settings\username\Application Data\appname under Windows
90 // and ~/Library/Application Support/appname under Mac
91 virtual wxString
GetUserDataDir() const = 0;
93 // return the directory for user data files which shouldn't be shared with
96 // same as GetUserDataDir() for all platforms except Windows where it is
97 // the "Local Settings\Application Data\appname" directory
98 virtual wxString
GetUserLocalDataDir() const;
100 // return the directory where the loadable modules (plugins) live
102 // prefix/lib/appname under Unix, program directory under Windows and
103 // Contents/Plugins app bundle subdirectory under Mac
104 virtual wxString
GetPluginsDir() const = 0;
106 // get resources directory: resources are auxiliary files used by the
107 // application and include things like image and sound files
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(); }
113 // get localized resources directory containing the resource files of the
114 // specified category for the given language
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)
121 GetLocalizedResourcesDir(const wxString
& lang
,
122 ResourceCat
WXUNUSED(category
)
123 = ResourceCat_None
) const
125 return GetResourcesDir() + wxFILE_SEP_PATH
+ lang
;
128 // return the "Documents" directory for the current user
130 // C:\Documents and Settings\username\My Documents under Windows,
131 // $HOME under Unix and ~/Documents under Mac
132 virtual wxString
GetDocumentsDir() const;
134 // return the directory for the documents files used by this application:
135 // it's a subdirectory of GetDocumentsDir() constructed using the
136 // application name/vendor if it exists or just GetDocumentsDir() otherwise
137 virtual wxString
GetAppDocumentsDir() const;
139 // return the temporary directory for the current user
140 virtual wxString
GetTempDir() const;
143 // ctor for the base class
144 wxStandardPathsBase();
146 // virtual dtor for the base class
147 virtual ~wxStandardPathsBase();
149 // Information used by AppendAppInfo
150 void UseAppInfo(int info
)
152 m_usedAppInfo
= info
;
155 bool UsesAppInfo(int info
) const { return (m_usedAppInfo
& info
) != 0; }
159 // append the path component, with a leading path separator if a
160 // path separator or dot (.) is not already at the end of dir
161 static wxString
AppendPathComponent(const wxString
& dir
, const wxString
& component
);
163 // append application information determined by m_usedAppInfo to dir
164 wxString
AppendAppInfo(const wxString
& dir
) const;
167 // combination of AppInfo_XXX flags used by AppendAppInfo()
172 #if defined(__WXMSW__)
173 #include "wx/msw/stdpaths.h"
174 #define wxHAS_NATIVE_STDPATHS
175 // We want CoreFoundation paths on both CarbonLib and Darwin (for all ports)
176 #elif defined(__WXMAC__) || defined(__DARWIN__)
177 #include "wx/osx/core/stdpaths.h"
178 #define wxHAS_NATIVE_STDPATHS
179 #elif defined(__OS2__)
180 #include "wx/os2/stdpaths.h"
181 #define wxHAS_NATIVE_STDPATHS
182 #elif defined(__UNIX__)
183 #include "wx/unix/stdpaths.h"
184 #define wxHAS_NATIVE_STDPATHS
185 #elif defined(__PALMOS__)
186 #include "wx/palmos/stdpaths.h"
187 #define wxHAS_NATIVE_STDPATHS
191 // ----------------------------------------------------------------------------
192 // Minimal generic implementation
193 // ----------------------------------------------------------------------------
195 // NB: Note that this minimal implementation is compiled in even if
196 // wxUSE_STDPATHS=0, so that our code can still use wxStandardPaths.
198 #ifndef wxHAS_NATIVE_STDPATHS
199 class WXDLLIMPEXP_BASE wxStandardPaths
: public wxStandardPathsBase
202 void SetInstallPrefix(const wxString
& prefix
) { m_prefix
= prefix
; }
203 wxString
GetInstallPrefix() const { return m_prefix
; }
205 virtual wxString
GetExecutablePath() const { return m_prefix
; }
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
; }
212 virtual wxString
GetDocumentsDir() const { return m_prefix
; }
217 #endif // !wxHAS_NATIVE_STDPATHS
219 #endif // _WX_STDPATHS_H_