allow to optionally use vendor name component in standard paths (slightly modified patch 1831308)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50025 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-11-17 14:59:13 +00:00
parent 180b5b4827
commit 2b147f2e19
8 changed files with 106 additions and 21 deletions

View File

@@ -77,6 +77,15 @@ wxStandardPathsBase& wxAppTraitsBase::GetStandardPaths()
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
@@ -104,23 +113,41 @@ wxString wxStandardPathsBase::GetTempDir() const
}
/* 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;
}