29 using System.Collections.Generic;
31 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Framework.Console;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
47 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"AssetInfoModule")]
52 private Scene m_scene;
54 public string Name {
get {
return "Asset Information Module"; } }
56 public Type ReplaceableInterface {
get {
return null; } }
90 MainConsole.Instance.Commands.AddCommand(
95 "Show asset information",
98 MainConsole.Instance.Commands.AddCommand(
99 "Assets",
false,
"dump asset",
105 void HandleDumpAsset(
string module,
string[] args)
109 MainConsole.Instance.Output(
"Usage is dump asset <ID>");
114 string rawAssetId = args[2];
116 if (!
UUID.TryParse(rawAssetId, out assetId))
118 MainConsole.Instance.OutputFormat(
"ERROR: {0} is not a valid ID format", rawAssetId);
122 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
125 MainConsole.Instance.OutputFormat(
"ERROR: No asset found with ID {0}", assetId);
129 string fileName = rawAssetId;
134 using (FileStream fs =
new FileStream(fileName, FileMode.CreateNew))
136 using (BinaryWriter bw =
new BinaryWriter(fs))
138 bw.Write(asset.Data);
142 MainConsole.Instance.OutputFormat(
"Asset dumped to file {0}", fileName);
145 void HandleShowAsset(
string module,
string[] args)
149 MainConsole.Instance.Output(
"Syntax: show asset <ID>");
153 AssetBase asset = m_scene.AssetService.Get(args[2]);
155 if (asset == null || asset.
Data.Length == 0)
157 MainConsole.Instance.Output(
"Asset not found");
163 MainConsole.Instance.OutputFormat(
"Name: {0}", asset.Name);
164 MainConsole.Instance.OutputFormat(
"Description: {0}", asset.Description);
165 MainConsole.Instance.OutputFormat(
"Type: {0} (type number = {1})", (AssetType)asset.
Type, asset.
Type);
166 MainConsole.Instance.OutputFormat(
"Content-type: {0}", asset.Metadata.ContentType);
167 MainConsole.Instance.OutputFormat(
"Size: {0} bytes", asset.Data.Length);
168 MainConsole.Instance.OutputFormat(
"Temporary: {0}", asset.Temporary ?
"yes" :
"no");
169 MainConsole.Instance.OutputFormat(
"Flags: {0}", asset.Metadata.Flags);
171 for (i = 0 ; i < 5 ; i++)
174 if (asset.
Data.Length <= off)
177 if (asset.
Data.Length < off + len)
178 len = asset.Data.Length - off;
180 byte[] line =
new byte[len];
181 Array.Copy(asset.Data, off, line, 0, len);
183 string text = BitConverter.ToString(line);
184 MainConsole.Instance.Output(String.Format(
"{0:x4}: {1}", off, text));
A module that just holds commands for inspecting assets.
sbyte Type
(sbyte) AssetType enum
Asset class. All Assets are reference by this class or a class derived from this class ...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
static ICommandConsole Instance
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
Interactive OpenSim region server
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
static bool CheckFileDoesNotExist(ICommandConsole console, string path)
Check if the given file path exists.
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...