aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs48
1 files changed, 47 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
index ca8e51e..e413466 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
@@ -26,6 +26,9 @@
26 */ 26 */
27 27
28using OpenSim.Region.Environment.Scenes; 28using OpenSim.Region.Environment.Scenes;
29using System.IO;
30using System.Collections.Generic;
31using System.Xml;
29 32
30namespace OpenSim.Region.Environment.Modules.ExportSerialiser 33namespace OpenSim.Region.Environment.Modules.ExportSerialiser
31{ 34{
@@ -33,11 +36,54 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
33 { 36 {
34 #region IFileSerialiser Members 37 #region IFileSerialiser Members
35 38
39
40 public void SaveSerialisedToFile(string fileName, Scene scene)
41 {
42 int primCount = 0;
43 string xmlstream = "<scene>";
44
45 List<EntityBase> EntityList = scene.GetEntities();
46 List<string> EntityXml = new List<string>();
47
48 foreach (EntityBase ent in EntityList)
49 {
50 if (ent is SceneObjectGroup)
51 {
52 EntityXml.Add(((SceneObjectGroup)ent).ToXmlString2());
53 primCount++;
54 }
55 }
56 EntityXml.Sort();
57
58 foreach (string xml in EntityXml)
59 xmlstream += xml;
60
61 xmlstream += "</scene>";
62
63 MemoryStream stream = new MemoryStream();
64 XmlTextWriter formatter = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
65 XmlDocument doc = new XmlDocument();
66
67 doc.LoadXml(xmlstream);
68 formatter.Formatting = Formatting.Indented;
69 doc.WriteContentTo(formatter);
70 formatter.Flush();
71 StreamReader reader = new StreamReader(stream);
72
73 stream.Seek(0, SeekOrigin.Begin);
74
75 FileStream objectsFile = new FileStream(fileName, FileMode.Create);
76 stream.WriteTo(objectsFile);
77 objectsFile.Flush();
78 objectsFile.Close();
79
80 }
81
36 public string WriteToFile(Scene scene, string dir) 82 public string WriteToFile(Scene scene, string dir)
37 { 83 {
38 string targetFileName = dir + "objects.xml"; 84 string targetFileName = dir + "objects.xml";
39 85
40 scene.SavePrimsToXml2(targetFileName); 86 SaveSerialisedToFile(targetFileName, scene);
41 87
42 return "objects.xml"; 88 return "objects.xml";
43 } 89 }