From fa5f27acfa753d5f9e15b222bb826ea4a5f313b6 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 26 Jun 2008 17:36:54 +0000 Subject: * Put extensions on all assets in an archive * Choice of extensions is a scratch set, may not yet be correct * This facility is not useable yet - not least because I've just come across a significant save bug I need to investigate --- .../Modules/World/Archiver/ArchiveConstants.cs | 63 ++++++++++++++++++++-- .../Modules/World/Archiver/AssetsArchiver.cs | 10 ++-- .../Modules/World/Archiver/AssetsDearchiver.cs | 7 ++- 3 files changed, 66 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index 388c541..843dd0c 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs @@ -25,6 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using libsecondlife; + namespace OpenSim.Region.Environment.Modules.World.Archiver { /// @@ -38,11 +41,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver public static readonly string ASSETS_PATH = "assets/"; /// - /// Extension used for texture assets in archive - /// - public static readonly string TEXTURE_EXTENSION = ".jp2"; - - /// /// Path for the assets metadata file /// public static readonly string ASSETS_METADATA_PATH = "assets.xml"; @@ -51,5 +49,60 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// Path for the prims file /// public static readonly string OBJECTS_PATH = "objects/"; + + /// + /// Extensions used for asset types in the archive + /// + public static readonly IDictionary ASSET_TYPE_TO_EXTENSION = new Dictionary(); + public static readonly IDictionary EXTENSION_TO_ASSET_TYPE = new Dictionary(); + + static ArchiveConstants() + { + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = ".bvh"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Bodypart] = ".bpt.txt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.CallingCard] = ".ccd.txt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Clothing] = ".clo.txt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Folder] = ".fld.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Gesture] = ".gst.txt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageJPEG] = ".jpg"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ".img.tga"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ".lff.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = ".lso"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = ".lsl"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ".ncd.txt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ".obj.xml"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ".rof.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Script] = ".spt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Simstate] = ".sst"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ".ssf.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Sound] = ".ogg"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ".wav"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ".jp2"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ".tga"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ".trf.txt"; // Not sure if we'll ever see this + + EXTENSION_TO_ASSET_TYPE[".bvh"] = (sbyte)AssetType.Animation; + EXTENSION_TO_ASSET_TYPE[".bpt.txt"] = (sbyte)AssetType.Bodypart; + EXTENSION_TO_ASSET_TYPE[".ccd.txt"] = (sbyte)AssetType.CallingCard; + EXTENSION_TO_ASSET_TYPE[".clo.txt"] = (sbyte)AssetType.Clothing; + EXTENSION_TO_ASSET_TYPE[".fld.txt"] = (sbyte)AssetType.Folder; + EXTENSION_TO_ASSET_TYPE[".gst.txt"] = (sbyte)AssetType.Gesture; + EXTENSION_TO_ASSET_TYPE[".jpg"] = (sbyte)AssetType.ImageJPEG; + EXTENSION_TO_ASSET_TYPE[".img.tga"] = (sbyte)AssetType.ImageTGA; + EXTENSION_TO_ASSET_TYPE[".lff.txt"] = (sbyte)AssetType.LostAndFoundFolder; + EXTENSION_TO_ASSET_TYPE[".lso"] = (sbyte)AssetType.LSLBytecode; + EXTENSION_TO_ASSET_TYPE[".lsl"] = (sbyte)AssetType.LSLText; + EXTENSION_TO_ASSET_TYPE[".ncd.txt"] = (sbyte)AssetType.Notecard; + EXTENSION_TO_ASSET_TYPE[".obj.xml"] = (sbyte)AssetType.Object; + EXTENSION_TO_ASSET_TYPE[".rof.txt"] = (sbyte)AssetType.RootFolder; + EXTENSION_TO_ASSET_TYPE[".spt"] = (sbyte)AssetType.Script; + EXTENSION_TO_ASSET_TYPE[".sst"] = (sbyte)AssetType.Simstate; + EXTENSION_TO_ASSET_TYPE[".ssf.txt"] = (sbyte)AssetType.SnapshotFolder; + EXTENSION_TO_ASSET_TYPE[".ogg"] = (sbyte)AssetType.Sound; + EXTENSION_TO_ASSET_TYPE[".wav"] = (sbyte)AssetType.SoundWAV; + EXTENSION_TO_ASSET_TYPE[".jp2"] = (sbyte)AssetType.Texture; + EXTENSION_TO_ASSET_TYPE[".tga"] = (sbyte)AssetType.TextureTGA; + EXTENSION_TO_ASSET_TYPE[".trf.txt"] = (sbyte)AssetType.TrashFolder; + } } } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs index 8b4708c..4922362 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs @@ -86,10 +86,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver string extension = string.Empty; - if ((sbyte)AssetType.Texture == asset.Type) + if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) { - extension = ArchiveConstants.TEXTURE_EXTENSION; - } + extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; + } xtw.WriteElementString("filename", uuid.ToString() + extension); @@ -125,9 +125,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { string extension = string.Empty; - if ((sbyte)AssetType.Texture == asset.Type) + if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) { - extension = ArchiveConstants.TEXTURE_EXTENSION; + extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; } archive.AddFile( diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs index 527d544..284a39e 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs @@ -148,11 +148,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { AssetMetadata metadata = m_metadata[filename]; - string extension = String.Empty; - - if ((sbyte)AssetType.Texture == metadata.AssetType) + if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(metadata.AssetType)) { - filename = filename.Remove(filename.Length - ArchiveConstants.TEXTURE_EXTENSION.Length); + string extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[metadata.AssetType]; + filename = filename.Remove(filename.Length - extension.Length); } m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); -- cgit v1.1