diff options
Diffstat (limited to 'OpenSim.GenericConfig')
-rw-r--r-- | OpenSim.GenericConfig/Xml/XmlConfig.cs | 25 |
1 files changed, 21 insertions, 4 deletions
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 | |||
12 | private XmlNode rootNode; | 12 | private XmlNode rootNode; |
13 | private XmlNode configNode; | 13 | private XmlNode configNode; |
14 | private string fileName; | 14 | private string fileName; |
15 | private bool createdFile = false; | ||
15 | 16 | ||
16 | public XmlConfig(string filename) | 17 | public XmlConfig(string filename) |
17 | { | 18 | { |
@@ -23,10 +24,22 @@ namespace OpenSim.GenericConfig | |||
23 | doc = new XmlDocument(); | 24 | doc = new XmlDocument(); |
24 | try | 25 | try |
25 | { | 26 | { |
26 | XmlTextReader reader = new XmlTextReader(fileName); | 27 | if (System.IO.File.Exists(fileName)) |
27 | reader.WhitespaceHandling = WhitespaceHandling.None; | 28 | { |
28 | doc.Load(reader); | 29 | XmlTextReader reader = new XmlTextReader(fileName); |
29 | reader.Close(); | 30 | reader.WhitespaceHandling = WhitespaceHandling.None; |
31 | doc.Load(reader); | ||
32 | reader.Close(); | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | createdFile = true; | ||
37 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); | ||
38 | doc.AppendChild(rootNode); | ||
39 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); | ||
40 | rootNode.AppendChild(configNode); | ||
41 | } | ||
42 | |||
30 | } | 43 | } |
31 | catch (Exception e) | 44 | catch (Exception e) |
32 | { | 45 | { |
@@ -48,6 +61,10 @@ namespace OpenSim.GenericConfig | |||
48 | { | 61 | { |
49 | Console.WriteLine(e.Message); | 62 | Console.WriteLine(e.Message); |
50 | } | 63 | } |
64 | if (createdFile) | ||
65 | { | ||
66 | this.Commit(); | ||
67 | } | ||
51 | } | 68 | } |
52 | 69 | ||
53 | public string GetAttribute(string attributeName) | 70 | public string GetAttribute(string attributeName) |