From 3183a20632c2c3b7ed9d18398a06585bb5f96012 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 2 Jul 2008 22:53:36 +0000 Subject: [PATCH] * Start writing out control file in archive. Only contains version information right now. --- .../World/Archiver/ArchiveConstants.cs | 5 +++ .../Archiver/ArchiveWriteRequestExecution.cs | 32 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index 22d1ed7d31..a5688ef380 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs @@ -35,6 +35,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// public class ArchiveConstants { + /// + /// The location of the archive control file + /// + public static readonly string CONTROL_FILE_PATH = "archive.xml"; + /// /// Path for the assets held in an archive /// diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs index 2c43ffd329..91de3c670e 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Xml; using libsecondlife; using log4net; using OpenSim.Framework; @@ -77,6 +78,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver TarArchiveWriter archive = new TarArchiveWriter(); + // Write out control file + archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile()); + // Write out terrain string terrainPath = String.Format("{0}{1}.png", ArchiveConstants.TERRAINS_PATH, m_sceneName); MemoryStream ms = new MemoryStream(); @@ -109,6 +113,32 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver archive.WriteTar(m_savePath); m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); - } + } + + /// + /// Create the control file for this archive + /// + /// + /// A + /// + protected string CreateControlFile() + { + StringWriter sw = new StringWriter(); + XmlTextWriter xtw = new XmlTextWriter(sw); + xtw.Formatting = Formatting.Indented; + xtw.WriteStartDocument(); + xtw.WriteStartElement("archive"); + xtw.WriteAttributeString("major_version", "0"); + xtw.WriteAttributeString("minor_version", "1"); + xtw.WriteEndElement(); + + xtw.Flush(); + xtw.Close(); + + String s = sw.ToString(); + sw.Close(); + + return s; + } } }