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
This commit is contained in:
Vadim Zeitlin
2006-03-25 18:31:44 +00:00
parent 1191c93ebc
commit adaa49a801
2 changed files with 27 additions and 4 deletions

View File

@@ -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();
};
// ----------------------------------------------------------------------------

View File

@@ -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();
}
// ============================================================================