1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of wxStandardPaths class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_STDPATHS_H_
12 #define _WX_STDPATHS_H_
16 #include "wx/string.h"
17 #include "wx/filefn.h"
19 class WXDLLIMPEXP_FWD_BASE wxStandardPaths
;
21 // ----------------------------------------------------------------------------
22 // wxStandardPaths returns the standard locations in the file system
23 // ----------------------------------------------------------------------------
25 // NB: This is always compiled in, wxUSE_STDPATHS=0 only disables native
26 // wxStandardPaths class, but a minimal version is always available
27 class WXDLLIMPEXP_BASE wxStandardPathsBase
30 // possible resources categories
33 // no special category
36 // message catalog resources
43 // what should we use to construct paths unique to this application:
44 // (AppInfo_AppName and AppInfo_VendorName can be combined together)
47 AppInfo_None
= 0, // nothing
48 AppInfo_AppName
= 1, // the application name
49 AppInfo_VendorName
= 2 // the vendor name
53 // return the global standard paths object
54 static wxStandardPaths
& Get();
56 // return the path (directory+filename) of the running executable or
57 // wxEmptyString if it couldn't be determined.
58 // The path is returned as an absolute path whenever possible.
59 // Default implementation only try to use wxApp->argv[0].
60 virtual wxString
GetExecutablePath() const;
62 // return the directory with system config files:
63 // /etc under Unix, c:\Documents and Settings\All Users\Application Data
64 // under Windows, /Library/Preferences for Mac
65 virtual wxString
GetConfigDir() const = 0;
67 // return the directory for the user config files:
68 // $HOME under Unix, c:\Documents and Settings\username under Windows,
69 // ~/Library/Preferences under Mac
71 // only use this if you have a single file to put there, otherwise
72 // GetUserDataDir() is more appropriate
73 virtual wxString
GetUserConfigDir() const = 0;
75 // return the location of the applications global, i.e. not user-specific,
78 // prefix/share/appname under Unix, c:\Program Files\appname under Windows,
79 // appname.app/Contents/SharedSupport app bundle directory under Mac
80 virtual wxString
GetDataDir() const = 0;
82 // return the location for application data files which are host-specific
84 // same as GetDataDir() except under Unix where it is /etc/appname
85 virtual wxString
GetLocalDataDir() const;
87 // return the directory for the user-dependent application data files
89 // $HOME/.appname under Unix,
90 // c:\Documents and Settings\username\Application Data\appname under Windows
91 // and ~/Library/Application Support/appname under Mac
92 virtual wxString
GetUserDataDir() const = 0;
94 // return the directory for user data files which shouldn't be shared with
97 // same as GetUserDataDir() for all platforms except Windows where it is
98 // the "Local Settings\Application Data\appname" directory
99 virtual wxString
GetUserLocalDataDir() const;
101 // return the directory where the loadable modules (plugins) live
103 // prefix/lib/appname under Unix, program directory under Windows and
104 // Contents/Plugins app bundle subdirectory under Mac
105 virtual wxString
GetPluginsDir() const = 0;
107 // get resources directory: resources are auxiliary files used by the
108 // application and include things like image and sound files
110 // same as GetDataDir() for all platforms except Mac where it returns
111 // Contents/Resources subdirectory of the app bundle
112 virtual wxString
GetResourcesDir() const { return GetDataDir(); }
114 // get localized resources directory containing the resource files of the
115 // specified category for the given language
117 // in general this is just GetResourcesDir()/lang under Windows and Unix
118 // and GetResourcesDir()/lang.lproj under Mac but is something quite
119 // different under Unix for message catalog category (namely the standard
120 // prefix/share/locale/lang/LC_MESSAGES)
122 GetLocalizedResourcesDir(const wxString
& lang
,
123 ResourceCat
WXUNUSED(category
)
124 = ResourceCat_None
) const
126 return GetResourcesDir() + wxFILE_SEP_PATH
+ lang
;
129 // return the "Documents" directory for the current user
131 // C:\Documents and Settings\username\My Documents under Windows,
132 // $HOME under Unix and ~/Documents under Mac
133 virtual wxString
GetDocumentsDir() const;
135 // return the directory for the documents files used by this application:
136 // it's a subdirectory of GetDocumentsDir() constructed using the
137 // application name/vendor if it exists or just GetDocumentsDir() otherwise
138 virtual wxString
GetAppDocumentsDir() const;
140 // return the temporary directory for the current user
141 virtual wxString
GetTempDir() const;
144 // virtual dtor for the base class
145 virtual ~wxStandardPathsBase();
147 // Information used by AppendAppInfo
148 void UseAppInfo(int info
)
150 m_usedAppInfo
= info
;
153 bool UsesAppInfo(int info
) const { return (m_usedAppInfo
& info
) != 0; }
157 // Ctor is protected as this is a base class which should never be created
159 wxStandardPathsBase();
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(__WINDOWS__)
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
; }
214 // Ctor is protected because wxStandardPaths::Get() should always be used
215 // to access the global wxStandardPaths object of the correct type instead
216 // of creating one of a possibly wrong type yourself.
217 wxStandardPaths() { }
222 #endif // !wxHAS_NATIVE_STDPATHS
224 #endif // _WX_STDPATHS_H_