Ejemplo n.º 1
0
        private void HandleDumpObjectById(string module, string[] cmdparams)
        {
            if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
            {
                return;
            }

            if (cmdparams.Length < 4)
            {
                m_console.OutputFormat("Usage: dump object id <UUID-or-localID>");
                return;
            }

            UUID objectUuid;
            uint localId;

            if (!ConsoleUtil.TryParseConsoleId(m_console, cmdparams[3], out objectUuid, out localId))
            {
                return;
            }

            SceneObjectGroup so;

            if (localId == ConsoleUtil.LocalIdNotFound)
            {
                so = m_scene.GetSceneObjectGroup(objectUuid);
            }
            else
            {
                so = m_scene.GetSceneObjectGroup(localId);
            }

            if (so == null)
            {
//                m_console.OutputFormat("No part found with uuid {0}", objectUuid);
                return;
            }

            // In case we found it via local ID.
            objectUuid = so.UUID;

            string fileName = string.Format("{0}.xml", objectUuid);

            if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName))
            {
                return;
            }

            using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
            {
                xtw.Formatting = Formatting.Indented;
                SceneObjectSerializer.ToOriginalXmlFormat(so, xtw, true);
            }

            m_console.OutputFormat("Object dumped to file {0}", fileName);
        }
Ejemplo n.º 2
0
        void HandleDumpAsset(string module, string[] args)
        {
            if (args.Length < 3)
            {
                MainConsole.Instance.Output("Usage is dump asset <ID>");
                return;
            }

            UUID   assetId;
            string rawAssetId = args[2];

            if (!UUID.TryParse(rawAssetId, out assetId))
            {
                MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
                return;
            }

            AssetBase asset = m_AssetService.Get(assetId.ToString());

            if (asset == null)
            {
                MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
                return;
            }

            string fileName = rawAssetId;

            if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
            {
                return;
            }

            using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
            {
                using (BinaryWriter bw = new BinaryWriter(fs))
                {
                    bw.Write(asset.Data);
                }
            }

            MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
        }