From ce336c6d76d8c513487af08857c1cd3cbe806d30 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 Oct 2004 00:34:32 +0000 Subject: [PATCH] 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 --- include/wx/msw/stdpaths.h | 3 --- include/wx/stdpaths.h | 5 +++++ src/common/stdpbase.cpp | 27 +++++++++++++++++++++++++++ src/msw/stdpaths.cpp | 16 ---------------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/include/wx/msw/stdpaths.h b/include/wx/msw/stdpaths.h index c1e9bb3f3c..e89e80b227 100644 --- a/include/wx/msw/stdpaths.h +++ b/include/wx/msw/stdpaths.h @@ -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); }; diff --git a/include/wx/stdpaths.h b/include/wx/stdpaths.h index c69f4435f6..e96bfcd681 100644 --- a/include/wx/stdpaths.h +++ b/include/wx/stdpaths.h @@ -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__) diff --git a/src/common/stdpbase.cpp b/src/common/stdpbase.cpp index 4d477a2974..58e9e4ebba 100644 --- a/src/common/stdpbase.cpp +++ b/src/common/stdpbase.cpp @@ -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; +} + diff --git a/src/msw/stdpaths.cpp b/src/msw/stdpaths.cpp index dcce507ce3..dcb164a576 100644 --- a/src/msw/stdpaths.cpp +++ b/src/msw/stdpaths.cpp @@ -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 // ---------------------------------------------------------------------------- -- 2.45.2