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 class WXDLLIMPEXP_FWD_BASE wxStandardPaths
;
22 // ----------------------------------------------------------------------------
23 // wxStandardPaths returns the standard locations in the file system
24 // ----------------------------------------------------------------------------
26 // NB: This is always compiled in, wxUSE_STDPATHS=0 only disables native
27 // wxStandardPaths class, but a minimal version is always available
28 class WXDLLIMPEXP_BASE wxStandardPathsBase
31 // possible resources categories
34 // no special category
37 // message catalog resources
44 // what should we use to construct paths unique to this application:
45 // (AppInfo_AppName and AppInfo_VendorName can be combined together)
48 AppInfo_None
= 0, // nothing
49 AppInfo_AppName
= 1, // the application name
50 AppInfo_VendorName
= 2 // the vendor name
54 // return the global standard paths object
55 static wxStandardPaths
& Get();
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;
63 // return the directory with system config files:
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;
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
72 // only use this if you have a single file to put there, otherwise
73 // GetUserDataDir() is more appropriate
74 virtual wxString
GetUserConfigDir() const = 0;
76 // return the location of the applications global, i.e. not user-specific,
79 // prefix/share/appname under Unix, c:\Program Files\appname under Windows,
80 // appname.app/Contents/SharedSupport app bundle directory under Mac
81 virtual wxString
GetDataDir() const = 0;
83 // return the location for application data files which are host-specific
85 // same as GetDataDir() except under Unix where it is /etc/appname
86 virtual wxString
GetLocalDataDir() const;
88 // return the directory for the user-dependent application data files
90 // $HOME/.appname under Unix,
91 // c:\Documents and Settings\username\Application Data\appname under Windows
92 // and ~/Library/Application Support/appname under Mac
93 virtual wxString
GetUserDataDir() const = 0;
95 // return the directory for user data files which shouldn't be shared with
98 // same as GetUserDataDir() for all platforms except Windows where it is
99 // the "Local Settings\Application Data\appname" directory
100 virtual wxString
GetUserLocalDataDir() const;
102 // return the directory where the loadable modules (plugins) live
104 // prefix/lib/appname under Unix, program directory under Windows and
105 // Contents/Plugins app bundle subdirectory under Mac
106 virtual wxString
GetPluginsDir() const = 0;
108 // get resources directory: resources are auxiliary files used by the
109 // application and include things like image and sound files
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(); }
115 // get localized resources directory containing the resource files of the
116 // specified category for the given language
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)
123 GetLocalizedResourcesDir(const wxString
& lang
,
124 ResourceCat
WXUNUSED(category
)
125 = ResourceCat_None
) const
127 return GetResourcesDir() + wxFILE_SEP_PATH
+ lang
;
130 // return the "Documents" directory for the current user
132 // C:\Documents and Settings\username\My Documents under Windows,
133 // $HOME under Unix and ~/Documents under Mac
134 virtual wxString
GetDocumentsDir() const;
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;
141 // return the temporary directory for the current user
142 virtual wxString
GetTempDir() const;
145 // ctor for the base class
146 wxStandardPathsBase();
148 // virtual dtor for the base class
149 virtual ~wxStandardPathsBase();
151 // Information used by AppendAppInfo
152 void UseAppInfo(int info
)
154 m_usedAppInfo
= info
;
157 bool UsesAppInfo(int info
) const { return (m_usedAppInfo
& info
) != 0; }
161 // append the path component, with a leading path separator if a
162 // path separator or dot (.) is not already at the end of dir
163 static wxString
AppendPathComponent(const wxString
& dir
, const wxString
& component
);
165 // append application information determined by m_usedAppInfo to dir
166 wxString
AppendAppInfo(const wxString
& dir
) const;
169 // combination of AppInfo_XXX flags used by AppendAppInfo()
174 #if defined(__WXMSW__)
175 #include "wx/msw/stdpaths.h"
176 #define wxHAS_NATIVE_STDPATHS
177 // We want CoreFoundation paths on both CarbonLib and Darwin (for all ports)
178 #elif defined(__WXMAC__) || defined(__DARWIN__)
179 #include "wx/osx/core/stdpaths.h"
180 #define wxHAS_NATIVE_STDPATHS
181 #elif defined(__OS2__)
182 #include "wx/os2/stdpaths.h"
183 #define wxHAS_NATIVE_STDPATHS
184 #elif defined(__UNIX__)
185 #include "wx/unix/stdpaths.h"
186 #define wxHAS_NATIVE_STDPATHS
190 // ----------------------------------------------------------------------------
191 // Minimal generic implementation
192 // ----------------------------------------------------------------------------
194 // NB: Note that this minimal implementation is compiled in even if
195 // wxUSE_STDPATHS=0, so that our code can still use wxStandardPaths.
197 #ifndef wxHAS_NATIVE_STDPATHS
198 class WXDLLIMPEXP_BASE wxStandardPaths
: public wxStandardPathsBase
201 void SetInstallPrefix(const wxString
& prefix
) { m_prefix
= prefix
; }
202 wxString
GetInstallPrefix() const { return m_prefix
; }
204 virtual wxString
GetExecutablePath() const { return m_prefix
; }
205 virtual wxString
GetConfigDir() const { return m_prefix
; }
206 virtual wxString
GetUserConfigDir() const { return m_prefix
; }
207 virtual wxString
GetDataDir() const { return m_prefix
; }
208 virtual wxString
GetLocalDataDir() const { return m_prefix
; }
209 virtual wxString
GetUserDataDir() const { return m_prefix
; }
210 virtual wxString
GetPluginsDir() const { return m_prefix
; }
211 virtual wxString
GetDocumentsDir() const { return m_prefix
; }
216 #endif // !wxHAS_NATIVE_STDPATHS
218 #endif // _WX_STDPATHS_H_