From f756b1ee1c93e842ae7ad4c64d1115586cac7382 Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 19 Oct 2007 19:20:18 +0000 Subject: [PATCH] *Added -useexecutepath to use the path of the .exe as the path to find configuration and libraries and not the current working directory. --- OpenSim/Framework/General/Util.cs | 24 +++++++++++++++++++++++ OpenSim/Region/Application/Application.cs | 1 + OpenSim/Region/Application/OpenSimMain.cs | 8 ++++++++ 3 files changed, 33 insertions(+) diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs index fe4ce29493..0c9a290af6 100644 --- a/OpenSim/Framework/General/Util.cs +++ b/OpenSim/Framework/General/Util.cs @@ -44,6 +44,8 @@ namespace OpenSim.Framework.Utilities private static object XferLock = new object(); private static Dictionary capsURLS = new Dictionary(); + private static bool m_useExecutePath; + public static ulong UIntsToLong(uint X, uint Y) { return Helpers.UIntsToLong(X, Y); @@ -295,12 +297,22 @@ namespace OpenSim.Framework.Utilities // // directory locations // + + public static void changeUseExecutePathSetting(bool setting) + { + m_useExecutePath = setting; + } + public static string homeDir() { string temp; // string personal=(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); // temp = Path.Combine(personal,".OpenSim"); temp="."; + if (m_useExecutePath) + { + temp = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + } return temp; } @@ -308,6 +320,10 @@ namespace OpenSim.Framework.Utilities { string temp; temp = "."; + if (m_useExecutePath) + { + temp = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + } return temp; } @@ -315,6 +331,10 @@ namespace OpenSim.Framework.Utilities { string temp; temp = "."; + if (m_useExecutePath) + { + temp = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + } return temp; } @@ -322,6 +342,10 @@ namespace OpenSim.Framework.Utilities { string temp; temp = "."; + if (m_useExecutePath) + { + temp = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + } return temp; } diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index ec7c43d23c..8e2793e3f5 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -65,6 +65,7 @@ namespace OpenSim configSource.AddSwitch("Startup", "gridmode"); configSource.AddSwitch("Startup", "physics"); configSource.AddSwitch("Startup", "noverbose"); + configSource.AddSwitch("Startup", "useexecutepath"); OpenSimMain sim = new OpenSimMain(configSource); diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 475314553b..5fb514f2ed 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -91,6 +91,14 @@ namespace OpenSim { IConfigSource startupSource = configSource; string iniFile = startupSource.Configs["Startup"].GetString("inifile", "OpenSim.ini"); + string useExecutePathString = startupSource.Configs["Startup"].GetString("useexecutepath", "false").ToLower(); + bool useExecutePath = false; + if (useExecutePathString == "true" || useExecutePathString == "" || useExecutePathString == "1" || useExecutePathString == "yes") + { + useExecutePath = true; + } + + Util.changeUseExecutePathSetting(useExecutePath); //check for .INI file (either default or name passed in command line) string iniFilePath = Path.Combine(Util.configDir(), iniFile);