is set during program configuration if using GNU autotools and so it is enough
to pass its value defined in \texttt{config.h} to this function.
+
+\membersection{wxStandardPaths::UseAppInfo}\label{wxstandardpathsuseappinfo}
+
+\func{void}{UseAppInfo}{\param{int }{info}}
+
+Controls what application information is used when constructing paths that
+should be unique to this program, such as the application data directory, the
+plugins directory on Unix, etc.
+
+Valid values for \arg{info} are \texttt{AppInfo\_None} and either one or
+combination of \texttt{AppInfo\_AppName} and \texttt{AppInfo\_VendorName}. The
+first one tells this class to not use neither application nor vendor name in
+the paths.
+
+By default, only the application name is used under Unix systems but both
+application and vendor names are used under Windows and Mac.
+
+\wxheading{See also}
+
+\helpref{wxApp::SetAppName}{wxappsetappname}, \helpref{wxApp::SetVendorName}{wxappsetvendorname}
+
class WXDLLIMPEXP_BASE wxStandardPaths : public wxStandardPathsBase
{
public:
+ wxStandardPaths()
+ {
+ UseAppInfo(AppInfo_AppName | AppInfo_VendorName);
+ }
+
+ ~wxStandardPaths() { }
+
// implement base class pure virtuals
virtual wxString GetExecutablePath() const;
virtual wxString GetConfigDir() const;
ResourceCat_Max
};
+ // what should we use to construct paths unique to this application:
+ // (AppInfo_AppName and AppInfo_VendorName can be combined together)
+ enum
+ {
+ AppInfo_None = 0, // nothing
+ AppInfo_AppName = 1, // the application name
+ AppInfo_VendorName = 2 // the vendor name
+ };
+
// return the global standard paths object
static wxStandardPathsBase& Get();
virtual wxString GetTempDir() const;
+ // ctor for the base class
+ wxStandardPathsBase();
+
// virtual dtor for the base class
virtual ~wxStandardPathsBase();
+ // Information used by AppendAppInfo
+ void UseAppInfo(int info)
+ {
+ m_usedAppInfo = info;
+ }
+
+ bool UsesAppInfo(int info) const { return (m_usedAppInfo & info) != 0; }
+
+
protected:
- // append "/appname" suffix if the app name is set (doesn't append the
- // slash if dir already ends with a slash or dot)
- static wxString AppendAppName(const wxString& dir);
+ // append the path component, with a leading path seperator if a
+ // path seperator or dot (.) is not already at the end of dir
+ static wxString AppendPathComponent(const wxString& dir, const wxString& component);
+
+ // append application information determined by m_usedAppInfo to dir
+ wxString AppendAppInfo(const wxString& dir) const;
+
+
+ // combination of AppInfo_XXX flags used by AppendAppInfo()
+ int m_usedAppInfo;
};
#if wxUSE_STDPATHS
return gs_stdPaths;
}
+wxStandardPathsBase::wxStandardPathsBase()
+{
+ // Set the default information that is used when
+ // forming some paths (by AppendAppInfo).
+ // Derived classes can call this in their constructors
+ // to set the platform-specific settings
+ UseAppInfo(AppInfo_AppName);
+}
+
wxStandardPathsBase::~wxStandardPathsBase()
{
// nothing to do here
}
/* static */
-wxString wxStandardPathsBase::AppendAppName(const wxString& dir)
+wxString wxStandardPathsBase::AppendPathComponent(const wxString& dir, const wxString& component)
{
wxString subdir(dir);
// empty string indicates that an error has occurred, don't touch it then
if ( !subdir.empty() )
{
- const wxString appname = wxTheApp->GetAppName();
- if ( !appname.empty() )
+ if ( !component.empty() )
{
const wxChar ch = *(subdir.end() - 1);
if ( !wxFileName::IsPathSeparator(ch) && ch != _T('.') )
subdir += wxFileName::GetPathSeparator();
- subdir += appname;
+ subdir += component;
}
}
return subdir;
}
+
+
+wxString wxStandardPathsBase::AppendAppInfo(const wxString& dir) const
+{
+ wxString subdir(dir);
+
+ if ( UsesAppInfo(AppInfo_VendorName) )
+ {
+ subdir = AppendPathComponent(subdir, wxTheApp->GetVendorName());
+ }
+
+ if ( UsesAppInfo(AppInfo_AppName) )
+ {
+ subdir = AppendPathComponent(subdir, wxTheApp->GetAppName());
+ }
+
+ return subdir;
+}
+
: m_bundle(CFBundleGetMainBundle())
{
CFRetain(m_bundle);
+ UseAppInfo(AppInfo_AppName | AppInfo_VendorName);
}
wxStandardPathsCF::wxStandardPathsCF(wxCFBundleRef bundle)
: m_bundle(bundle)
{
CFRetain(m_bundle);
+ UseAppInfo(AppInfo_AppName | AppInfo_VendorName);
}
wxStandardPathsCF::~wxStandardPathsCF()
wxString wxStandardPathsCF::GetLocalDataDir() const
{
#ifdef __WXMAC__
- return AppendAppName(wxMacFindFolder((short)kLocalDomain, kApplicationSupportFolderType, kCreateFolder));
+ return AppendAppInfo(wxMacFindFolder((short)kLocalDomain, kApplicationSupportFolderType, kCreateFolder));
#else
- return AppendAppName(wxT("/Library/Application Support"));
+ return AppendAppInfo(wxT("/Library/Application Support"));
#endif
}
wxString wxStandardPathsCF::GetUserDataDir() const
{
#ifdef __WXMAC__
- return AppendAppName(wxMacFindFolder((short)kUserDomain, kApplicationSupportFolderType, kCreateFolder));
+ return AppendAppInfo(wxMacFindFolder((short)kUserDomain, kApplicationSupportFolderType, kCreateFolder));
#else
- return AppendAppName(wxFileName::GetHomeDir() + _T("/Library/Application Support"));
+ return AppendAppInfo(wxFileName::GetHomeDir() + _T("/Library/Application Support"));
#endif
}
wxString wxStandardPaths::GetConfigDir() const
{
- return AppendAppName(DoGetDirectory(CSIDL_COMMON_APPDATA));
+ return AppendAppInfo(DoGetDirectory(CSIDL_COMMON_APPDATA));
}
wxString wxStandardPaths::GetUserConfigDir() const
wxString wxStandardPaths::GetUserDataDir() const
{
- return AppendAppName(GetUserConfigDir());
+ return AppendAppInfo(GetUserConfigDir());
}
wxString wxStandardPaths::GetUserLocalDataDir() const
{
- return AppendAppName(DoGetDirectory(CSIDL_LOCAL_APPDATA));
+ return AppendAppInfo(DoGetDirectory(CSIDL_LOCAL_APPDATA));
}
wxString wxStandardPaths::GetPluginsDir() const
wxString wxStandardPaths::GetUserDataDir() const
{
- return AppendAppName(wxFileName::GetHomeDir() + _T("\\."));
+ return AppendAppInfo(wxFileName::GetHomeDir() + _T("\\."));
}
wxString wxStandardPaths::GetPluginsDir() const
wxString wxStandardPaths::GetDataDir() const
{
- return AppendAppName(GetInstallPrefix() + _T("/sys$share"));
+ return AppendAppInfo(GetInstallPrefix() + _T("/sys$share"));
}
wxString wxStandardPaths::GetLocalDataDir() const
{
- return AppendAppName(_T("/sys$manager"));
+ return AppendAppInfo(_T("/sys$manager"));
}
wxString wxStandardPaths::GetUserDataDir() const
wxString wxStandardPaths::GetDataDir() const
{
- return AppendAppName(GetInstallPrefix() + _T("/share"));
+ return AppendAppInfo(GetInstallPrefix() + _T("/share"));
}
wxString wxStandardPaths::GetLocalDataDir() const
{
- return AppendAppName(_T("/etc"));
+ return AppendAppInfo(_T("/etc"));
}
wxString wxStandardPaths::GetUserDataDir() const
{
- return AppendAppName(wxFileName::GetHomeDir() + _T("/."));
+ return AppendAppInfo(wxFileName::GetHomeDir() + _T("/."));
}
wxString wxStandardPaths::GetPluginsDir() const
{
- return AppendAppName(GetInstallPrefix() + _T("/lib"));
+ return AppendAppInfo(GetInstallPrefix() + _T("/lib"));
}
wxString