aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2008-04-21 04:36:32 +0000
committerAdam Frisby2008-04-21 04:36:32 +0000
commit20a4a402f6e3a1f914ee562f9e2d16647bcb961d (patch)
tree23c276d6cc92ee399f9ffdc2b3b4adb17cb86726 /OpenSim
parent* Added support for periodic autosaves - added to SvnBackupModule. Will cause... (diff)
downloadopensim-SC_OLD-20a4a402f6e3a1f914ee562f9e2d16647bcb961d.zip
opensim-SC_OLD-20a4a402f6e3a1f914ee562f9e2d16647bcb961d.tar.gz
opensim-SC_OLD-20a4a402f6e3a1f914ee562f9e2d16647bcb961d.tar.bz2
opensim-SC_OLD-20a4a402f6e3a1f914ee562f9e2d16647bcb961d.tar.xz
* Written a improved self-contained version of the XML Object Serialiser for the ExportSerialisationModule.
* This now outputs properly indented XML, that is sorted before construction. This produces a file which proper .diffs can be generated from - the end result being smaller more compact revisions when saving to SVN. * Files are a little heavy still however, compression looks like a good method for packing sim-states for transport outside of SVN. Zip seems to be a good candidate and is on the TODO.
Diffstat (limited to 'OpenSim')
-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 }