From fdc9ed89b4adaa7f23ca06613b2ee36c30895021 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 2 Apr 2007 15:48:01 +0000 Subject: OpenSim no longer uses OpenSim.Config.SimConfigDb4o, it now uses OpenSim.GenericConfig.Xml (or a class implementing IGenericConfig). --- OpenSim.GenericConfig/Xml/XmlConfig.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'OpenSim.GenericConfig/Xml') diff --git a/OpenSim.GenericConfig/Xml/XmlConfig.cs b/OpenSim.GenericConfig/Xml/XmlConfig.cs index 39321cc..c398229 100644 --- a/OpenSim.GenericConfig/Xml/XmlConfig.cs +++ b/OpenSim.GenericConfig/Xml/XmlConfig.cs @@ -12,6 +12,7 @@ namespace OpenSim.GenericConfig private XmlNode rootNode; private XmlNode configNode; private string fileName; + private bool createdFile = false; public XmlConfig(string filename) { @@ -23,10 +24,22 @@ namespace OpenSim.GenericConfig doc = new XmlDocument(); try { - XmlTextReader reader = new XmlTextReader(fileName); - reader.WhitespaceHandling = WhitespaceHandling.None; - doc.Load(reader); - reader.Close(); + if (System.IO.File.Exists(fileName)) + { + XmlTextReader reader = new XmlTextReader(fileName); + reader.WhitespaceHandling = WhitespaceHandling.None; + doc.Load(reader); + reader.Close(); + } + else + { + createdFile = true; + rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); + doc.AppendChild(rootNode); + configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); + rootNode.AppendChild(configNode); + } + } catch (Exception e) { @@ -48,6 +61,10 @@ namespace OpenSim.GenericConfig { Console.WriteLine(e.Message); } + if (createdFile) + { + this.Commit(); + } } public string GetAttribute(string attributeName) -- cgit v1.1