public ArchiveReadRequest(IScene scene, string loadPath, bool merge, bool skipAssets, int offsetX, int offsetY, int offsetZ, bool flipX, bool flipY, bool useParcelOwnership, bool checkOwnership) { try { var stream = ArchiveHelpers.GetStream(loadPath); if (stream == null) { MainConsole.Instance.Error( "[ARCHIVER]: We could not find the file specified, or the file was invalid: " + loadPath); return; } m_loadStream = new GZipStream(stream, CompressionMode.Decompress); } catch (EntryPointNotFoundException e) { MainConsole.Instance.ErrorFormat( "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); MainConsole.Instance.Error(e); } Init(scene, m_loadStream, merge, skipAssets, offsetX, offsetY, offsetZ, flipX, flipY, useParcelOwnership, checkOwnership); }
public InventoryArchiveReadRequest( IRegistryCore registry, UserAccount userInfo, string invPath, string loadPath, bool merge, UUID overwriteCreator) { Stream str = ArchiveHelpers.GetStream(loadPath); if (str == null) { return; } m_registry = registry; m_merge = merge; m_userInfo = userInfo; m_invName = Path.GetFileNameWithoutExtension(loadPath); m_invPath = invPath.StartsWith("/", StringComparison.Ordinal) ? invPath.Remove(0, 1) : invPath; m_loadStream = new GZipStream(str, CompressionMode.Decompress); m_overridecreator = overwriteCreator; // we will need these at some time m_assetService = m_registry.RequestModuleInterface <IAssetService> (); m_assetData = Framework.Utilities.DataManager.RequestPlugin <IAssetDataPlugin> (); m_inventoryService = m_registry.RequestModuleInterface <IInventoryService> (); m_accountService = m_registry.RequestModuleInterface <IUserAccountService> (); }
void LoadWhiteCoreArchive(IScene scene, string[] cmd) { string fileName = MainConsole.Instance.Prompt("What file name should we load?", scene.RegionInfo.RegionName + ".abackup"); // a couple of sanity checks string extension = Path.GetExtension(fileName); if (extension == string.Empty) { fileName = fileName + ".abackup"; } if (!File.Exists(fileName)) { MainConsole.Instance.Info("[Archiver]: Region archive file '" + fileName + "' not found."); return; } var stream = ArchiveHelpers.GetStream(fileName); if (stream == null) { MainConsole.Instance.Warn("No file found with the specified name."); return; } GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); LoadRegionBackup(reader, scene); GC.Collect(); }
private void LoadAuroraArchive(string[] cmd) { IScene scene = MainConsole.Instance.ConsoleScene; if (scene == null) { MainConsole.Instance.Warn("Select a region first."); return; } string fileName = MainConsole.Instance.Prompt("What file name should we load?", scene.RegionInfo.RegionName + ".abackup"); var stream = ArchiveHelpers.GetStream(fileName); if (stream == null) { MainConsole.Instance.Warn("No file found with the specified name."); return; } GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); LoadRegionBackup(reader, scene); GC.Collect(); }
public InventoryArchiveReadRequest( Scene scene, UserAccount userInfo, string invPath, string loadPath) : this( scene, userInfo, invPath, new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress)) { }
public InventoryArchiveReadRequest( IRegistryCore registry, UserAccount userInfo, string invPath, string loadPath, bool merge) : this( registry, userInfo, invPath, new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress), merge) { }
public InventoryArchiveReadRequest( IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, string loadPath, bool merge) : this( inv, assets, uacc, userInfo, invPath, new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress), merge) { }
private void LoadAuroraArchive(string mod, string[] cmd) { IScene scene = MainConsole.Instance.ConsoleScene; if (scene == null) { m_log.Warn("Select a region first."); return; } string fileName = MainConsole.Instance.CmdPrompt("What file name should we load?", scene.RegionInfo.RegionName + ".backup"); GZipStream m_loadStream = new GZipStream(ArchiveHelpers.GetStream(fileName), CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); }
private void LoadIAR(string fileName) { //Load the iar into memory TarArchiveReader archive = new TarArchiveReader(new GZipStream(ArchiveHelpers.GetStream(fileName), CompressionMode.Decompress)); byte[] data; TarArchiveReader.TarEntryType entryType; string filePath; InventoryFolderBase rootDestFolder = new InventoryFolderBase(UUID.Zero, UUID.Zero); Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary <string, InventoryFolderBase> (); while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { LoadAsset(filePath, data); } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); // Trim off the file portion if we aren't already dealing with a directory path if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) { filePath = filePath.Remove(filePath.LastIndexOf("/") + 1); } InventoryFolderBase foundFolder = ReplicateArchivePathToUserInventory( filePath, rootDestFolder, ref resolvedFolders); if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) { LoadItem(data, foundFolder); } } } archive.Close(); //Got the .iar loaded into memory now // Time to put it into the GUI RebuildTreeView(); }
public InventoryArchiveReadRequest( IRegistryCore registry, UserAccount userInfo, string invPath, string loadPath, bool merge, UUID overwriteCreator) { Stream str = ArchiveHelpers.GetStream(loadPath); if (str == null) { return; } m_registry = registry; m_merge = merge; m_userInfo = userInfo; m_invPath = invPath; m_loadStream = new GZipStream(str, CompressionMode.Decompress); m_overridecreator = overwriteCreator; }
protected virtual void ReadBackup(IScene scene) { MainConsole.Instance.Debug("[FileBasedSimulationData]: Reading file for " + scene.RegionInfo.RegionName); List <uint> foundLocalIDs = new List <uint>(); var stream = ArchiveHelpers.GetStream((m_loadDirectory == "" || m_loadDirectory == "/") ? m_fileName : Path.Combine(m_loadDirectory, m_fileName)); if (stream == null) { lock (m_saveLock) { if (!m_shutdown) { SaveBackup(m_saveDirectory, false); } } return; } GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); byte[] data; string filePath; TarArchiveReader.TarEntryType entryType; System.Collections.Concurrent.ConcurrentQueue <byte[]> groups = new System.Collections.Concurrent.ConcurrentQueue <byte[]>(); //Load the archive data that we need while ((data = reader.ReadEntry(out filePath, out entryType)) != null) { if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) { continue; } if (filePath.StartsWith("parcels/")) { //Only use if we are not merging LandData parcel = new LandData(); OSD parcelData = OSDParser.DeserializeLLSDBinary(data); parcel.FromOSD((OSDMap)parcelData); m_parcels.Add(parcel); } else if (filePath.StartsWith("terrain/")) { m_oldstyleterrain = data; } else if (filePath.StartsWith("revertterrain/")) { m_oldstylerevertTerrain = data; } else if (filePath.StartsWith("newstyleterrain/")) { m_terrain = data; } else if (filePath.StartsWith("newstylerevertterrain/")) { m_revertTerrain = data; } else if (filePath.StartsWith("newstylewater/")) { m_water = data; } else if (filePath.StartsWith("newstylerevertwater/")) { m_revertWater = data; } else if (filePath.StartsWith("entities/")) { MemoryStream ms = new MemoryStream(data); SceneObjectGroup sceneObject = SceneObjectSerializer.FromXml2Format(ref ms, scene); ms.Close(); ms = null; data = null; foreach (ISceneChildEntity part in sceneObject.ChildrenEntities()) { if (!foundLocalIDs.Contains(part.LocalId)) { foundLocalIDs.Add(part.LocalId); } else { part.LocalId = 0; //Reset it! Only use it once! } } m_groups.Add(sceneObject); } data = null; } m_loadStream.Close(); m_loadStream = null; foundLocalIDs.Clear(); GC.Collect(); }
public RegionData LoadBackup(string file) { if (!File.Exists(file)) { return(null); } var stream = ArchiveHelpers.GetStream(file); if (stream == null) { return(null); } GZipStream m_loadStream = new GZipStream(stream, CompressionMode.Decompress); TarArchiveReader reader = new TarArchiveReader(m_loadStream); List <uint> foundLocalIDs = new List <uint>(); RegionData regiondata = new RegionData(); regiondata.Init(); byte[] data; string filePath; TarArchiveReader.TarEntryType entryType; System.Collections.Concurrent.ConcurrentQueue <byte[]> groups = new System.Collections.Concurrent.ConcurrentQueue <byte[]>(); //Load the archive data that we need while ((data = reader.ReadEntry(out filePath, out entryType)) != null) { if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) { continue; } if (filePath.StartsWith("parcels/")) { //Only use if we are not merging LandData parcel = new LandData(); OSD parcelData = OSDParser.DeserializeLLSDBinary(data); parcel.FromOSD((OSDMap)parcelData); if (parcel.OwnerID != UUID.Parse("05948863-b678-433e-87a4-e44d17678d1d")) { //The default owner of the 'default' region regiondata.Parcels.Add(parcel); } } else if (filePath.StartsWith("newstyleterrain/")) { regiondata.Terrain = data; } else if (filePath.StartsWith("newstylerevertterrain/")) { regiondata.RevertTerrain = data; } else if (filePath.StartsWith("newstylewater/")) { regiondata.Water = data; } else if (filePath.StartsWith("newstylerevertwater/")) { regiondata.RevertWater = data; } else if (filePath.StartsWith("entities/")) { groups.Enqueue(data); } else if (filePath.StartsWith("regioninfo/")) { RegionInfo info = new RegionInfo(); info.FromOSD((OSDMap)OSDParser.DeserializeLLSDBinary(data)); regiondata.RegionInfo = info; } data = null; } m_loadStream.Close(); m_loadStream = null; int threadCount = groups.Count > 16 ? 16 : groups.Count; System.Threading.Thread[] threads = new System.Threading.Thread[threadCount]; for (int i = 0; i < threadCount; i++) { threads[i] = new System.Threading.Thread(() => { byte[] groupData; while (groups.TryDequeue(out groupData)) { MemoryStream ms = new MemoryStream(groupData); ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer .FromXml2Format(ref ms, null); ms.Close(); ms = null; data = null; if (sceneObject != null) { foreach ( ISceneChildEntity part in sceneObject.ChildrenEntities()) { lock (foundLocalIDs) { if ( !foundLocalIDs.Contains( part.LocalId)) { foundLocalIDs.Add(part.LocalId); } else { part.LocalId = 0; } //Reset it! Only use it once! } } regiondata.Groups.Add( sceneObject as SceneObjectGroup); } } }); threads[i].Start(); } for (int i = 0; i < threadCount; i++) { threads[i].Join(); } foundLocalIDs.Clear(); return(regiondata); }