From adaa49a801c69360fb57d13e1fe8aef7022c3b34 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 25 Mar 2006 18:31:44 +0000 Subject: [PATCH] discard the debug directories at the end of the executable path automatically in debug builds to allow running the programs without installing them git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38373 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/stdpaths.h | 5 +++-- src/msw/stdpaths.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/stdpaths.h b/include/wx/msw/stdpaths.h index c12729857e..5273872dce 100644 --- a/include/wx/msw/stdpaths.h +++ b/include/wx/msw/stdpaths.h @@ -26,12 +26,13 @@ public: virtual wxString GetUserDataDir() const; virtual wxString GetUserLocalDataDir() const; virtual wxString GetPluginsDir() const; - virtual wxString GetLocalizedResourcesDir(const wxChar *lang, - ResourceCat category) const; protected: // get the path corresponding to the given standard CSIDL_XXX constant static wxString DoGetDirectory(int csidl); + + // return the directory of the application itself + static wxString GetAppDir(); }; // ---------------------------------------------------------------------------- diff --git a/src/msw/stdpaths.cpp b/src/msw/stdpaths.cpp index 2a7a046dd6..5e9de59ee3 100644 --- a/src/msw/stdpaths.cpp +++ b/src/msw/stdpaths.cpp @@ -242,6 +242,26 @@ wxString wxStandardPaths::DoGetDirectory(int csidl) return dir; } +/* static */ +wxString wxStandardPaths::GetAppDir() +{ + wxFileName fn(wxGetFullModuleName()); + + // allow running the apps directly from build directory in debug builds +#ifdef __WXDEBUG__ + wxString lastdir; + if ( fn.GetDirCount() ) + { + lastdir = fn.GetDirs().Last(); + lastdir.MakeLower(); + if ( lastdir.Matches(_T("debug*")) || lastdir.Matches(_T("vc_msw*")) ) + fn.RemoveLastDir(); + } +#endif // __WXDEBUG__ + + return fn.GetPath(); +} + // ---------------------------------------------------------------------------- // public functions // ---------------------------------------------------------------------------- @@ -260,7 +280,7 @@ wxString wxStandardPaths::GetDataDir() const { // under Windows each program is usually installed in its own directory and // so its datafiles are in the same directory as its main executable - return wxFileName(wxGetFullModuleName()).GetPath(); + return GetAppDir(); } wxString wxStandardPaths::GetUserDataDir() const @@ -275,7 +295,9 @@ wxString wxStandardPaths::GetUserLocalDataDir() const wxString wxStandardPaths::GetPluginsDir() const { - return wxFileName(wxGetFullModuleName()).GetPath(); + // there is no standard location for plugins, suppose they're in the same + // directory as the .exe + return GetAppDir(); } // ============================================================================ -- 2.45.2