From da0fc3c8f572adba69e52e1d7f528946ab1f6f23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 21:11:32 +0000 Subject: Make "show asset" command available simulator side. Actually make the service command be "show asset" instead of "show digest" this time. Last time I accidnetally just changed the usage message. --- .../OptionalModules/Asset/AssetInfoModule.cs | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Asset') diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs index 9ea6343..a5207eb 100644 --- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs @@ -88,6 +88,14 @@ namespace OpenSim.Region.OptionalModules.Asset m_scene = scene; MainConsole.Instance.Commands.AddCommand( + "asset", + false, + "show asset", + "show asset ", + "Show asset information", + HandleShowAsset); + + MainConsole.Instance.Commands.AddCommand( "asset", false, "dump asset", "dump asset ", "Dump an asset", @@ -130,5 +138,48 @@ namespace OpenSim.Region.OptionalModules.Asset MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); } + + void HandleShowAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: show asset "); + return; + } + + AssetBase asset = m_scene.AssetService.Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + int i; + + MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); + MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); + MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); + MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); + MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length); + MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no"); + MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); + + for (i = 0 ; i < 5 ; i++) + { + int off = i * 16; + if (asset.Data.Length <= off) + break; + int len = 16; + if (asset.Data.Length < off + len) + len = asset.Data.Length - off; + + byte[] line = new byte[len]; + Array.Copy(asset.Data, off, line, 0, len); + + string text = BitConverter.ToString(line); + MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + } + } } } \ No newline at end of file -- cgit v1.1