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
43 // return the global standard paths object
44 static wxStandardPathsBase
& Get();
46 // return the path (directory+filename) of the running executable or
47 // wxEmptyString if it couldn't be determined.
48 // The path is returned as an absolute path whenever possible.
49 // Default implementation only try to use wxApp->argv[0].
50 virtual wxString
GetExecutablePath() const;
52 // return the directory with system config files:
53 // /etc under Unix, c:\Documents and Settings\All Users\Application Data
54 // under Windows, /Library/Preferences for Mac
55 virtual wxString
GetConfigDir() const = 0;
57 // return the directory for the user config files:
58 // $HOME under Unix, c:\Documents and Settings\username under Windows,
59 // ~/Library/Preferences under Mac
61 // only use this if you have a single file to put there, otherwise
62 // GetUserDataDir() is more appropriate
63 virtual wxString
GetUserConfigDir() const = 0;
65 // return the location of the applications global, i.e. not user-specific,
68 // prefix/share/appname under Unix, c:\Program Files\appname under Windows,
69 // appname.app/Contents/SharedSupport app bundle directory under Mac
70 virtual wxString
GetDataDir() const = 0;
72 // return the location for application data files which are host-specific
74 // same as GetDataDir() except under Unix where it is /etc/appname
75 virtual wxString
GetLocalDataDir() const;
77 // return the directory for the user-dependent application data files
79 // $HOME/.appname under Unix,
80 // c:\Documents and Settings\username\Application Data\appname under Windows
81 // and ~/Library/Application Support/appname under Mac
82 virtual wxString
GetUserDataDir() const = 0;
84 // return the directory for user data files which shouldn't be shared with
87 // same as GetUserDataDir() for all platforms except Windows where it is
88 // the "Local Settings\Application Data\appname" directory
89 virtual wxString
GetUserLocalDataDir() const;
91 // return the directory where the loadable modules (plugins) live
93 // prefix/lib/appname under Unix, program directory under Windows and
94 // Contents/Plugins app bundle subdirectory under Mac
95 virtual wxString
GetPluginsDir() const = 0;
97 // get resources directory: resources are auxiliary files used by the
98 // application and include things like image and sound files
100 // same as GetDataDir() for all platforms except Mac where it returns
101 // Contents/Resources subdirectory of the app bundle
102 virtual wxString
GetResourcesDir() const { return GetDataDir(); }
104 // get localized resources directory containing the resource files of the
105 // specified category for the given language
107 // in general this is just GetResourcesDir()/lang under Windows and Unix
108 // and GetResourcesDir()/lang.lproj under Mac but is something quite
109 // different under Unix for message catalog category (namely the standard
110 // prefix/share/locale/lang/LC_MESSAGES)
112 GetLocalizedResourcesDir(const wxString
& lang
,
113 ResourceCat
WXUNUSED(category
)
114 = ResourceCat_None
) const
116 return GetResourcesDir() + wxFILE_SEP_PATH
+ lang
;
119 // return the "Documents" directory for the current user
121 // C:\Documents and Settings\username\Documents under Windows,
122 // $HOME under Unix and ~/Documents under Mac
123 virtual wxString
GetDocumentsDir() const;
125 // return the temporary directory for the current user
126 virtual wxString
GetTempDir() const;
129 // virtual dtor for the base class
130 virtual ~wxStandardPathsBase();
133 // append "/appname" suffix if the app name is set (doesn't append the
134 // slash if dir already ends with a slash or dot)
135 static wxString
AppendAppName(const wxString
& dir
);
139 #if defined(__WXMSW__)
140 #include "wx/msw/stdpaths.h"
141 #define wxHAS_NATIVE_STDPATHS
142 // We want CoreFoundation paths on both CarbonLib and Darwin (for all ports)
143 #elif defined(__WXMAC__) || defined(__DARWIN__)
144 #include "wx/mac/corefoundation/stdpaths.h"
145 #define wxHAS_NATIVE_STDPATHS
146 #elif defined(__OS2__)
147 #include "wx/os2/stdpaths.h"
148 #define wxHAS_NATIVE_STDPATHS
149 #elif defined(__UNIX__)
150 #include "wx/unix/stdpaths.h"
151 #define wxHAS_NATIVE_STDPATHS
152 #elif defined(__PALMOS__)
153 #include "wx/palmos/stdpaths.h"
154 #define wxHAS_NATIVE_STDPATHS
158 // ----------------------------------------------------------------------------
159 // Minimal generic implementation
160 // ----------------------------------------------------------------------------
162 // NB: Note that this minimal implementation is compiled in even if
163 // wxUSE_STDPATHS=0, so that our code can still use wxStandardPaths.
165 #ifndef wxHAS_NATIVE_STDPATHS
166 class WXDLLIMPEXP_BASE wxStandardPaths
: public wxStandardPathsBase
169 void SetInstallPrefix(const wxString
& prefix
) { m_prefix
= prefix
; }
170 wxString
GetInstallPrefix() const { return m_prefix
; }
172 virtual wxString
GetExecutablePath() const { return m_prefix
; }
173 virtual wxString
GetConfigDir() const { return m_prefix
; }
174 virtual wxString
GetUserConfigDir() const { return m_prefix
; }
175 virtual wxString
GetDataDir() const { return m_prefix
; }
176 virtual wxString
GetLocalDataDir() const { return m_prefix
; }
177 virtual wxString
GetUserDataDir() const { return m_prefix
; }
178 virtual wxString
GetPluginsDir() const { return m_prefix
; }
179 virtual wxString
GetDocumentsDir() const { return m_prefix
; }
184 #endif // !wxHAS_NATIVE_STDPATHS
186 #endif // _WX_STDPATHS_H_