// Configuration.cs created with MonoDevelop // User: chadk at 12:51 PMĀ 12/23/2007 // // To change standard headers go to Edit->Preferences->Coding->Standard Headers // using System; using System.IO; using System.Text.RegularExpressions; namespace Lunar { public class Configuration { private const string LOCAL_CONFIGURATION_FILE = @"/etc/lunar/local/config"; public const string DEFAULT_MOONBASE_LOCATION = @"/var/lib/lunar/moonbase"; public Configuration() { } public static string MoonbaseLocation() { string strLocation = DEFAULT_MOONBASE_LOCATION; // Check for custom developer moonbase FileInfo customConfigFile = new FileInfo(LOCAL_CONFIGURATION_FILE); if (customConfigFile.Exists) { // Is there a "MOONBASE=" line in there? Regex search = new Regex(@"\s*MOONBASE\s*=\s*(.+)"); MatchCollection matches = search.Matches(customConfigFile.OpenText().ReadToEnd()); if (matches.Count > 0) { if (matches.Count > 1) { throw new FormatException(@"There is more than one MOONBASE listed in" + customConfigFile.FullName + ". Please fix this."); } strLocation = matches[0].Groups[1].Value; } } return strLocation; } } }