当前位置: 首页>>代码示例>>C#>>正文


C# TarArchiveWriter.WriteFile方法代码示例

本文整理汇总了C#中OpenSim.Framework.Serialization.TarArchiveWriter.WriteFile方法的典型用法代码示例。如果您正苦于以下问题:C# TarArchiveWriter.WriteFile方法的具体用法?C# TarArchiveWriter.WriteFile怎么用?C# TarArchiveWriter.WriteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Framework.Serialization.TarArchiveWriter的用法示例。


在下文中一共展示了TarArchiveWriter.WriteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveModuleToArchive

        public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
        {
            writer.WriteDir("windlight");

            foreach (RegionLightShareData lsd in m_WindlightSettings.Values)
            {
                OSDMap map = lsd.ToOSD();
                writer.WriteFile("windlight/" + lsd.UUID.ToString(), OSDParser.SerializeLLSDBinary(map));
            }
        }
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:10,代码来源:WindLightSettingsModule.cs

示例2: SaveModuleToArchive

            public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
            {
                m_isArchiving = true;

                m_log.Info("[Archive]: Writing parcels to archive");

                writer.WriteDir("parcels");

                IParcelManagementModule module = scene.RequestModuleInterface<IParcelManagementModule>();
                if (module != null)
                {
                    List<ILandObject> landObject = module.AllParcels();
                    foreach (ILandObject parcel in landObject)
                    {
                        OSDMap parcelMap = parcel.LandData.ToOSD();
                        writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(), OSDParser.SerializeLLSDBinary(parcelMap));
                    }
                }

                m_log.Info("[Archive]: Finished writing parcels to archive");
                m_log.Info("[Archive]: Writing terrain to archive");

                writer.WriteDir("terrain");

                ITerrainModule tModule = scene.RequestModuleInterface<ITerrainModule>();
                if (tModule != null)
                {
                    MemoryStream s = new MemoryStream();
                    tModule.SaveToStream(scene.RegionInfo.RegionID.ToString() + ".r32", s);
                    writer.WriteFile("terrain/" + scene.RegionInfo.RegionID.ToString() + ".r32", s.ToArray());
                    s.Close();
                }

                m_log.Info("[Archive]: Finished writing terrain to archive");
                m_log.Info("[Archive]: Writing entities to archive");
                ISceneEntity[] entities = scene.Entities.GetEntities();
                //Get all entities, then start writing them to the database
                writer.WriteDir("entities");

                IDictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>();
                UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);

                foreach (ISceneEntity entity in entities)
                {
                    //Write all entities
                    writer.WriteFile("entities/" + entity.UUID.ToString(), ((ISceneObject)entity).ToXml2());
                    //Get all the assets too
                    assetGatherer.GatherAssetUuids(entity, assets, scene);
                }

                m_log.Info("[Archive]: Finished writing entities to archive");
                m_log.Info("[Archive]: Writing assets for entities to archive");

                bool foundAllAssets = true;
                foreach (UUID assetID in new List<UUID>(assets.Keys))
                {
                    AssetBase asset = m_scene.AssetService.GetCached(assetID.ToString());
                    if (asset != null)
                        WriteAsset(asset, writer); //Write it syncronously since we havn't 
                    else
                    {
                        foundAllAssets = false; //Not all are cached
                        m_missingAssets.Add(assetID);
                        m_scene.AssetService.Get(assetID.ToString(), writer, RetrievedAsset);
                    }
                }
                if (foundAllAssets)
                    m_isArchiving = false; //We're done if all the assets were found

                m_log.Info("[Archive]: Finished writing assets for entities to archive");
            }
开发者ID:x8ball,项目名称:Aurora-Sim,代码行数:71,代码来源:Backup.cs

示例3: TestLoadMultiRegionOar

        public void TestLoadMultiRegionOar()
        {
            TestHelpers.InMethod();

            // Create an ArchiveScenesGroup with the regions in the OAR. This is needed to generate the control file.

            int WIDTH = 2;
            int HEIGHT = 2;

            for (uint y = 0; y < HEIGHT; y++)
            {
                for (uint x = 0; x < WIDTH; x++)
                {
                    Scene scene;
                    if (x == 0 && y == 0)
                    {
                        scene = m_scene;   // this scene was already created in SetUp()
                    }
                    else
                    {
                        scene = m_sceneHelpers.SetupScene(string.Format("Unit test region {0}", (y * WIDTH) + x + 1), UUID.Random(), 1000 + x, 1000 + y);
                        SceneHelpers.SetupSceneModules(scene, new ArchiverModule(), m_serialiserModule, new TerrainModule());
                    }
                }
            }

            ArchiveScenesGroup scenesGroup = new ArchiveScenesGroup();
            m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene)
            {
                scenesGroup.AddScene(scene);
            });
            scenesGroup.CalcSceneLocations();

            // Generate the OAR file

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            ArchiveWriteRequest writeRequest = new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty);
            writeRequest.MultiRegionFormat = true;
            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH, writeRequest.CreateControlFile(scenesGroup));

            SceneObjectPart part1 = CreateSceneObjectPart1();
            part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f);
            part1.SitTargetPosition = new Vector3(1, 2, 3);

            SceneObjectGroup object1 = new SceneObjectGroup(part1);

            // Let's put some inventory items into our object
            string soundItemName = "sound-item1";
            UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
            Type type = GetType();
            Assembly assembly = type.Assembly;
            string soundDataResourceName = null;
            string[] names = assembly.GetManifestResourceNames();
            foreach (string name in names)
            {
                if (name.EndsWith(".Resources.test-sound.wav"))
                    soundDataResourceName = name;
            }
            Assert.That(soundDataResourceName, Is.Not.Null);

            byte[] soundData;
            UUID soundUuid;
            CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid);

            TaskInventoryItem item1
                = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
            part1.Inventory.AddInventoryItem(item1, true);
            m_scene.AddNewSceneObject(object1, false);

            string object1FileName = string.Format(
                "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
                part1.Name,
                Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
                part1.UUID);
            string path = "regions/1_1_Unit_test_region/" + ArchiveConstants.OBJECTS_PATH + object1FileName;
            tar.WriteFile(path, SceneObjectSerializer.ToXml2Format(object1));

            tar.Close();

            
            // Delete the current objects, to test that they're loaded from the OAR and didn't
            // just remain in the scene.
            m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene)
            {
                scene.DeleteAllSceneObjects();
            });

            // Create a "hole", to test that that the corresponding region isn't loaded from the OAR
            m_sceneHelpers.SceneManager.CloseScene(SceneManager.Instance.Scenes[1]);


            // Check thay the OAR file contains the expected data

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            lock (this)
            {
//.........这里部分代码省略.........
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:101,代码来源:ArchiverTests.cs

示例4: TestLoadIarV0_1AbsentUsers

        public void TestLoadIarV0_1AbsentUsers()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();
            
            string userFirstName = "Charlie";
            string userLastName = "Chan";
            UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
            string userItemCreatorFirstName = "Bat";
            string userItemCreatorLastName = "Man";
            //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
            
            string itemName = "b.lsl";
            string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = itemName;
            item1.AssetID = UUID.Random();
            item1.GroupID = UUID.Random();
            item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
            //item1.CreatorId = userUuid.ToString();
            //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
            item1.Owner = UUID.Zero;
            
            string item1FileName 
                = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
            tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
            SerialiserModule serialiserModule = new SerialiserModule();
            InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
            
            // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
            Scene scene = SceneSetupHelpers.SetupScene("inventory");
            
            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
            UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
            
            archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);

            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName);
            
            Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
//            Assert.That(
//                foundItem1.CreatorId, Is.EqualTo(userUuid), 
//                "Loaded item non-uuid creator doesn't match that of the loading user");
            Assert.That(
                foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), 
                "Loaded item uuid creator doesn't match that of the loading user");
        }
开发者ID:RevolutionSmythe,项目名称:Aurora-Sim,代码行数:55,代码来源:InventoryArchiverTests.cs

示例5: TestLoadOar

        public void TestLoadOar()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
            
            // Put in a random blank directory to check that this doesn't upset the load process
            tar.WriteDir("ignoreme");
            
            // Also check that direct entries which will also have a file entry containing that directory doesn't 
            // upset load
            tar.WriteDir(ArchiveConstants.TERRAINS_PATH);

            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
            SceneObjectPart part1 = CreateSceneObjectPart1();

            part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f);
            part1.SitTargetPosition = new Vector3(1, 2, 3);

            SceneObjectGroup object1 = new SceneObjectGroup(part1);

            // Let's put some inventory items into our object
            string soundItemName = "sound-item1";
            UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
            Type type = GetType();
            Assembly assembly = type.Assembly;
            string soundDataResourceName = null;
            string[] names = assembly.GetManifestResourceNames();
            foreach (string name in names)
            {
                if (name.EndsWith(".Resources.test-sound.wav"))
                    soundDataResourceName = name;
            }
            Assert.That(soundDataResourceName, Is.Not.Null);

            byte[] soundData;
            UUID soundUuid;
            CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid);

            TaskInventoryItem item1
                = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
            part1.Inventory.AddInventoryItem(item1, true);
            m_scene.AddNewSceneObject(object1, false);

            string object1FileName = string.Format(
                "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
                part1.Name,
                Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
                part1.UUID);
            tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
            
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(archiveReadStream);
            }
            
            Assert.That(m_lastErrorMessage, Is.Null);

            TestLoadedRegion(part1, soundItemName, soundData);
        }
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:69,代码来源:ArchiverTests.cs

示例6: TestLoadOarDeededLand

        public void TestLoadOarDeededLand()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID landID = TestHelpers.ParseTail(0x10);

            MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();

            IConfigSource configSource = new IniConfigSource();
            IConfig config = configSource.AddConfig("Groups");            
            config.Set("Enabled", true);
            config.Set("Module", "GroupsModule");            
            config.Set("DebugEnabled", true);
            SceneHelpers.SetupSceneModules(
                m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });

            // Create group in scene for loading
            // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
            UUID groupID 
                = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);

            // Construct OAR
            MemoryStream oarStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(oarStream);

            tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));

            LandObject lo = new LandObject(groupID, true, m_scene);
            lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
            LandData ld = lo.LandData;
            ld.GlobalID = landID;

            string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
            Dictionary<string, object> options = new Dictionary<string, object>();
            tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options));
            tar.Close();

            oarStream = new MemoryStream(oarStream.ToArray());

            // Load OAR
            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(oarStream);
            }

            ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
            LandData rLd = rLo.LandData;

            Assert.That(rLd.GlobalID, Is.EqualTo(landID));
            Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
            Assert.That(rLd.GroupID, Is.EqualTo(groupID));
            Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
        }
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:58,代码来源:ArchiverTests.cs

示例7: TestLoadIarV0_1TempProfiles

        /// <summary>
        /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
        /// no account exists with the creator name
        /// </summary>
        /// Disabled since temporary profiles have not yet been implemented.
        //[Test]
        public void TestLoadIarV0_1TempProfiles()
        {
            TestHelper.InMethod();
            
            //log4net.Config.XmlConfigurator.Configure();
            
            string userFirstName = "Dennis";
            string userLastName = "Menace";
            UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa");
            string user2FirstName = "Walter";
            string user2LastName = "Mitty";
            
            string itemName = "b.lsl";
            string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = itemName;
            item1.AssetID = UUID.Random();
            item1.GroupID = UUID.Random();
            item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
            item1.Owner = UUID.Zero;
            
            string item1FileName 
                = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
            tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
            SerialiserModule serialiserModule = new SerialiserModule();
            InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
            
            // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
            Scene scene = SceneSetupHelpers.SetupScene();
            IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
            
            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
            userAdminService.AddUser(
                userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
            
            archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
            
            // Check that a suitable temporary user profile has been created.
            UserProfileData user2Profile 
                = scene.CommsManager.UserService.GetUserProfile(
                    OspResolver.HashName(user2FirstName + " " + user2LastName));
            Assert.That(user2Profile, Is.Not.Null);
            Assert.That(user2Profile.FirstName == user2FirstName);
            Assert.That(user2Profile.SurName == user2LastName);
            
            CachedUserInfo userInfo 
                = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
            userInfo.OnInventoryReceived += InventoryReceived;

            lock (this)
            {
                userInfo.FetchInventory();
                Monitor.Wait(this, 60000);
            }
            
            InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
            
            Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
            Assert.That(
                foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName)));
            Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
            
            Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod());
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:77,代码来源:InventoryArchiverTests.cs

示例8: ArchiveRegion

        /// <summary>
        /// Archive the region requested.
        /// </summary>
        /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
        public void ArchiveRegion(Dictionary<string, object> options)
        {
            m_options = options;

            if (options.ContainsKey("all") && (bool)options["all"])
                MultiRegionFormat = true;

            if (options.ContainsKey("noassets") && (bool)options["noassets"])
                SaveAssets = false;

            Object temp;
            if (options.TryGetValue("checkPermissions", out temp))
                FilterContent = (string)temp;


            // Find the regions to archive
            ArchiveScenesGroup scenesGroup = new ArchiveScenesGroup();
            if (MultiRegionFormat)
            {
                m_log.InfoFormat("[ARCHIVER]: Saving {0} regions", SceneManager.Instance.Scenes.Count);
                SceneManager.Instance.ForEachScene(delegate(Scene scene)
                {
                    scenesGroup.AddScene(scene);
                });
            }
            else
            {
                scenesGroup.AddScene(m_rootScene);
            }
            scenesGroup.CalcSceneLocations();

            m_archiveWriter = new TarArchiveWriter(m_saveStream);

            try
            {
                // Write out control file. It should be first so that it will be found ASAP when loading the file.
                m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(scenesGroup));
                m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");

                // Archive the regions

                Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>();

                scenesGroup.ForEachScene(delegate(Scene scene)
                {
                    string regionDir = MultiRegionFormat ? scenesGroup.GetRegionDir(scene.RegionInfo.RegionID) : "";
                    ArchiveOneRegion(scene, regionDir, assetUuids);
                });

                // Archive the assets

                if (SaveAssets)
                {
                    m_log.DebugFormat("[ARCHIVER]: Saving {0} assets", assetUuids.Count);

                    // Asynchronously request all the assets required to perform this archive operation
                    AssetsRequest ar
                        = new AssetsRequest(
                            new AssetsArchiver(m_archiveWriter), assetUuids,
                            m_rootScene.AssetService, m_rootScene.UserAccountService,
                            m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets);

                    WorkManager.RunInThread(o => ar.Execute(), null, "Archive Assets Request");

                    // CloseArchive() will be called from ReceivedAllAssets()
                }
                else
                {
                    m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified");
                    CloseArchive(string.Empty);
                }
            }
            catch (Exception e)
            {
                CloseArchive(e.Message);
                throw;
            }
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:82,代码来源:ArchiveWriteRequest.cs

示例9: SaveBackup

        /// <summary>
        /// Save a backup of the sim
        /// </summary>
        /// <param name="appendedFilePath">The file path where the backup will be saved</param>
        protected virtual void SaveBackup (string appendedFilePath, bool saveAssets)
        {
            if (appendedFilePath == "/")
                appendedFilePath = "";
            IBackupModule backupModule = m_scene.RequestModuleInterface<IBackupModule> ();
            if (backupModule != null && backupModule.LoadingPrims) //Something is changing lots of prims
            {
                m_log.Info ("[Backup]: Not saving backup because the backup module is loading prims");
                return;
            }

            //Save any script state saves that might be around
            IScriptModule[] engines = m_scene.RequestModuleInterfaces<IScriptModule> ();
            try
            {
                if (engines != null)
                {
                    foreach (IScriptModule engine in engines)
                    {
                        if (engine != null)
                        {
                            engine.SaveStateSaves ();
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString());
            }

            m_log.Info ("[FileBasedSimulationData]: Saving Backup for region " + m_scene.RegionInfo.RegionName);
            string fileName = appendedFilePath + m_scene.RegionInfo.RegionName + m_saveAppenedFileName + ".abackup";
            if (File.Exists (fileName))
            {
                //Do new style saving here!
                GZipStream m_saveStream = new GZipStream (new FileStream (fileName + ".tmp", FileMode.Create), CompressionMode.Compress);
                TarArchiveWriter writer = new TarArchiveWriter (m_saveStream);
                GZipStream m_loadStream = new GZipStream (new FileStream (fileName, FileMode.Open), CompressionMode.Decompress);
                TarArchiveReader reader = new TarArchiveReader (m_loadStream);

                writer.WriteDir ("parcels");

                IParcelManagementModule module = m_scene.RequestModuleInterface<IParcelManagementModule> ();
                if (module != null)
                {
                    List<ILandObject> landObject = module.AllParcels ();
                    foreach (ILandObject parcel in landObject)
                    {
                        OSDMap parcelMap = parcel.LandData.ToOSD ();
                        writer.WriteFile ("parcels/" + parcel.LandData.GlobalID.ToString (), OSDParser.SerializeLLSDBinary (parcelMap));
                        parcelMap = null;
                    }
                }

                writer.WriteDir ("newstyleterrain");
                writer.WriteDir ("newstylerevertterrain");

                writer.WriteDir ("newstylewater");
                writer.WriteDir ("newstylerevertwater");

                ITerrainModule tModule = m_scene.RequestModuleInterface<ITerrainModule> ();
                if (tModule != null)
                {
                    try
                    {
                        byte[] sdata = WriteTerrainToStream (tModule.TerrainMap);
                        writer.WriteFile ("newstyleterrain/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
                        sdata = null;

                        sdata = WriteTerrainToStream (tModule.TerrainRevertMap);
                        writer.WriteFile ("newstylerevertterrain/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
                        sdata = null;

                        if (tModule.TerrainWaterMap != null)
                        {
                            sdata = WriteTerrainToStream (tModule.TerrainWaterMap);
                            writer.WriteFile ("newstylewater/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
                            sdata = null;

                            sdata = WriteTerrainToStream (tModule.TerrainWaterRevertMap);
                            writer.WriteFile ("newstylerevertwater/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
                            sdata = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString ());
                    }
                }

                IDictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>();
                UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
                
                ISceneEntity[] saveentities = m_scene.Entities.GetEntities();
                List<UUID> entitiesToSave = new List<UUID>();
//.........这里部分代码省略.........
开发者ID:NickyPerian,项目名称:Aurora-Sim,代码行数:101,代码来源:FileBasedSimulationData.cs

示例10: TestLoadIarV0_1ExistingUsers

        public void TestLoadIarV0_1ExistingUsers()
        {
            TestHelper.InMethod();
            
            //log4net.Config.XmlConfigurator.Configure();
            
            string userFirstName = "Mr";
            string userLastName = "Tiddles";
            UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
            string userItemCreatorFirstName = "Lord";
            string userItemCreatorLastName = "Lucan";
            UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
            
            string item1Name = "b.lsl";
            string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random());

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = item1Name;
            item1.AssetID = UUID.Random();
            item1.GroupID = UUID.Random();
            item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
            //item1.CreatorId = userUuid.ToString();
            //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
            item1.Owner = UUID.Zero;
            
            string item1FileName 
                = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
            tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
            SerialiserModule serialiserModule = new SerialiserModule();
            InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
            
            // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
            Scene scene = SceneSetupHelpers.SetupScene("inventory");
            IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
            
            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
            userAdminService.AddUser(
                userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
            userAdminService.AddUser(
                userItemCreatorFirstName, userItemCreatorLastName, "hampshire", 
                String.Empty, 1000, 1000, userItemCreatorUuid);
            
            archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);

            CachedUserInfo userInfo 
                = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);

            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name);
            
            Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");

// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
// UUID, not the OSPA itself.
//            Assert.That(
//                foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), 
//                "Loaded item non-uuid creator doesn't match original");
            Assert.That(
                foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), 
                "Loaded item non-uuid creator doesn't match original");
            
            Assert.That(
                foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), 
                "Loaded item uuid creator doesn't match original");
            Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
                "Loaded item owner doesn't match inventory reciever");

            // Now try loading to a root child folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
            archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
            archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream);

            InventoryItemBase foundItem2
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name);
            Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");

            // Now try loading to a more deeply nested folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
            archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
            archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream);

            InventoryItemBase foundItem3
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name);
            Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:91,代码来源:InventoryArchiverTests.cs

示例11: TestLoadOarV0_2RegionSettings

        public void TestLoadOarV0_2RegionSettings()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
            
            tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
            tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));

            RegionSettings rs = new RegionSettings();
            rs.AgentLimit = 17;
            rs.AllowDamage = true;
            rs.AllowLandJoinDivide = true;
            rs.AllowLandResell = true;
            rs.BlockFly = true;
            rs.BlockShowInSearch = true;
            rs.BlockTerraform = true;
            rs.DisableCollisions = true;
            rs.DisablePhysics = true;
            rs.DisableScripts = true;
            rs.Elevation1NW = 15.9;
            rs.Elevation1NE = 45.3;
            rs.Elevation1SE = 49;
            rs.Elevation1SW = 1.9;
            rs.Elevation2NW = 4.5;
            rs.Elevation2NE = 19.2;
            rs.Elevation2SE = 9.2;
            rs.Elevation2SW = 2.1;
            rs.FixedSun = true;
            rs.ObjectBonus = 1.4;
            rs.RestrictPushing = true;
            rs.TerrainLowerLimit = 0.4;
            rs.TerrainRaiseLimit = 17.9;
            rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
            rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
            rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
            rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
            rs.UseEstateSun = true;
            rs.WaterHeight = 23;

            tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));
            
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(archiveReadStream);
            }
            
            Assert.That(m_lastErrorMessage, Is.Null);
            RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;

            Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
            Assert.That(loadedRs.AllowDamage, Is.True);
            Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
            Assert.That(loadedRs.AllowLandResell, Is.True);
            Assert.That(loadedRs.BlockFly, Is.True);
            Assert.That(loadedRs.BlockShowInSearch, Is.True);
            Assert.That(loadedRs.BlockTerraform, Is.True);
            Assert.That(loadedRs.DisableCollisions, Is.True);
            Assert.That(loadedRs.DisablePhysics, Is.True);
            Assert.That(loadedRs.DisableScripts, Is.True);
            Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
            Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
            Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
            Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
            Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
            Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
            Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
            Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
            Assert.That(loadedRs.FixedSun, Is.True);
            Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
            Assert.That(loadedRs.RestrictPushing, Is.True);
            Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
            Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
            Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020")));
            Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040")));
            Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060")));
            Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080")));
            Assert.That(loadedRs.UseEstateSun, Is.True);
            Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
        }
开发者ID:N3X15,项目名称:VoxelSim,代码行数:87,代码来源:ArchiverTests.cs

示例12: TestLoadIarV0_1ExistingUsers

        /// <summary>
        /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
        /// an account exists with the creator name.
        /// </summary>
        //[Test]
        public void TestLoadIarV0_1ExistingUsers()
        {   
            TestHelper.InMethod();
            
            log4net.Config.XmlConfigurator.Configure();
            
            string userFirstName = "Mr";
            string userLastName = "Tiddles";
            UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
            string userItemCreatorFirstName = "Lord";
            string userItemCreatorLastName = "Lucan";
            UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
            
            string itemName = "b.lsl";
            string archiveItemName
                = string.Format("{0}{1}{2}", itemName, "_", UUID.Random());            

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = itemName;
            item1.AssetID = UUID.Random();
            item1.GroupID = UUID.Random();
            item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
            //item1.CreatorId = userUuid.ToString();
            //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
            item1.Owner = UUID.Zero;
            
            string item1FileName 
                = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
            tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());            
            SerialiserModule serialiserModule = new SerialiserModule();
            InventoryArchiverModule archiverModule = new InventoryArchiverModule();
            
            // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
            Scene scene = SceneSetupHelpers.SetupScene();
            IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
            
            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
            userAdminService.AddUser(
                userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
            userAdminService.AddUser(
                userItemCreatorFirstName, userItemCreatorLastName, "hampshire", 
                String.Empty, 1000, 1000, userItemCreatorUuid);
            
            archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);

            CachedUserInfo userInfo 
                = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
            //userInfo.FetchInventory();
            /*
            for (int i = 0 ; i < 50 ; i++)
            {
                if (userInfo.HasReceivedInventory == true)
                    break;
                Thread.Sleep(200);
            }
            Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
            */
            InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
            Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item");
            Assert.That(
                foundItem.CreatorId, Is.EqualTo(item1.CreatorId), 
                "Loaded item non-uuid creator doesn't match original");
            Assert.That(
                foundItem.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), 
                "Loaded item uuid creator doesn't match original");
            Assert.That(foundItem.Owner, Is.EqualTo(userUuid),
                "Loaded item owner doesn't match inventory reciever");
        }
开发者ID:Ideia-Boa,项目名称:Diva-s-OpenSim-Tests,代码行数:79,代码来源:InventoryArchiverTests.cs

示例13: doExport

        /// <summary>
        /// 
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="GTAIV"></param>
        /// <returns></returns>
        private bool doExport(string filePath, DataSetType data_type )
        {
            //  Initial stage for the export/import functionality is the ability to export/import
            // the data correctly for the current city, uses OSDMap. For now the GTAIV flag is
            // ignored, this needs to be changed to allow for internal, GTA and GIS data sets to
            // be used for cities.
            if (filePath == null || data_type == DataSetType.DATASET_TYPE_NULL)
            {
                return (false);
            }

            //  Make sure the file is not present on the destination.
            // ???

            // First stage use a TarArchiveWriter in conjunction with OSDMap to write a file
            // containing all the information needed about the city and regions to be able to
            // import it in when the server is shutdown and restarted.
            System.IO.MemoryStream data = new System.IO.MemoryStream(1024);
            TarArchiveWriter tarArchive = null;

            //  Construct the archive before writing it to the destination.
            tarArchive = new TarArchiveWriter(data);
            tarArchive.WriteDir("citybuilder/");
            tarArchive.WriteFile(filePath, data.GetBuffer());

            return (false);
        }
开发者ID:CobraElDiablo,项目名称:CityModule,代码行数:33,代码来源:CityModule.cs

示例14: TestLoadOarV0_2

        public void TestLoadOarV0_2()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            MemoryStream archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
            
            // Put in a random blank directory to check that this doesn't upset the load process
            tar.WriteDir("ignoreme");
            
            // Also check that direct entries which will also have a file entry containing that directory doesn't 
            // upset load
            tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
            
            tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());

            SceneObjectPart part1 = CreateSceneObjectPart1();
            SceneObjectGroup object1 = new SceneObjectGroup(part1);

            // Let's put some inventory items into our object
            string soundItemName = "sound-item1";
            UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
            Type type = GetType();
            Assembly assembly = type.Assembly;
            string soundDataResourceName = null;
            string[] names = assembly.GetManifestResourceNames();
            foreach (string name in names)
            {
                if (name.EndsWith(".Resources.test-sound.wav"))
                    soundDataResourceName = name;
            }
            Assert.That(soundDataResourceName, Is.Not.Null);

            byte[] soundData;
            Console.WriteLine("Loading " + soundDataResourceName);
            using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName))
            {
                using (BinaryReader br = new BinaryReader(resource))
                {
                    // FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion
                    soundData = br.ReadBytes(99999999);
                    UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
                    string soundAssetFileName 
                       = ArchiveConstants.ASSETS_PATH + soundUuid 
                            + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
                    tar.WriteFile(soundAssetFileName, soundData);
                    
                    /*
                    AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData);
                    scene.AssetService.Store(soundAsset);
                    asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
                    */
                    
                    TaskInventoryItem item1 
                        = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
                    part1.Inventory.AddInventoryItem(item1, true);
                }
            }
            
            m_scene.AddNewSceneObject(object1, false);

            string object1FileName = string.Format(
                "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
                part1.Name,
                Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
                part1.UUID);
            tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
            
            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(archiveReadStream);
            }
            
            Assert.That(m_lastErrorMessage, Is.Null);

            SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name);

            Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded");
            Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical");
            Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal");
            Assert.That(
                object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal");
            Assert.That(
                object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal");

            TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0];
            Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null");
            AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
            Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
            Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");

            // Temporary
            Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:100,代码来源:ArchiverTests.cs

示例15: WriteInventoryItemToArchive

 private static void WriteInventoryItemToArchive(TarArchiveWriter archive, InventoryItemBase item, string path)
 {
     string filename = string.Format("{0}{1}_{2}.xml", path, item.Name, item.ID);
     string serialization = UserInventoryItemSerializer.Serialize(item);
     archive.WriteFile(filename, serialization);            
     
     //m_assetGatherer.GatherAssetUuids(item.AssetID, (AssetType) item.AssetType, assetUuids);
 }
开发者ID:ChrisD,项目名称:opensim,代码行数:8,代码来源:InventoryArchivePlugin.cs


注:本文中的OpenSim.Framework.Serialization.TarArchiveWriter.WriteFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。