moved AppendAppName() from MSW to common code; modified it to not double the trailing slash, if any

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2004-10-20 00:34:32 +00:00
parent a39490aee6
commit ce336c6d76
4 changed files with 32 additions and 19 deletions

View File

@ -28,9 +28,6 @@ public:
virtual wxString GetPluginsDir() const;
protected:
// append "/appname" suffix if the app name is set
static wxString AppendAppName(const wxString& dir);
// get the path corresponding to the given standard CSIDL_XXX constant
static wxString DoGetDirectory(int csidl);
};

View File

@ -75,6 +75,11 @@ public:
// virtual dtor for the base class
virtual ~wxStandardPathsBase();
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);
};
#if defined(__WXMSW__)

View File

@ -24,6 +24,11 @@
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#endif //WX_PRECOMP
#include "wx/filename.h"
#include "wx/stdpaths.h"
// ----------------------------------------------------------------------------
@ -57,3 +62,25 @@ wxString wxStandardPathsBase::GetUserLocalDataDir() const
return GetUserDataDir();
}
/* static */
wxString wxStandardPathsBase::AppendAppName(const wxString& dir)
{
wxString subdir(dir);
// empty string indicates that an error has occured, don't touch it then
if ( !subdir.empty() )
{
const wxString appname = wxTheApp->GetAppName();
if ( !appname.empty() )
{
const wxChar ch = *(subdir.end() - 1);
if ( !wxFileName::IsPathSeparator(ch) && ch != _T('.') )
subdir += wxFileName::GetPathSeparator();
subdir += appname;
}
}
return subdir;
}

View File

@ -216,22 +216,6 @@ wxString wxStandardPaths::DoGetDirectory(int csidl)
return dir;
}
/* static */
wxString wxStandardPaths::AppendAppName(const wxString& dir)
{
wxString subdir(dir);
// empty string indicates that an error has occured, don't touch it then
if ( !subdir.empty() )
{
const wxString appname = wxTheApp->GetAppName();
if ( !appname.empty() )
subdir << _T('\\') << appname;
}
return subdir;
}
// ----------------------------------------------------------------------------
// public functions
// ----------------------------------------------------------------------------