public XmlDocument LoadSectorXml() { var filename = Path.Combine(Savepath, SpaceEngineersConsts.SandBoxCheckpointFilename); var xDoc = new XmlDocument(); try { if (ZipTools.IsGzipedFile(filename)) { // New file format is compressed. // These steps could probably be combined, but would have to use a MemoryStream, which has memory limits before it causes performance issues when chunking memory. // Using a temporary file in this situation has less performance issues as it's moved straight to disk. var tempFilename = TempfileUtil.NewFilename(); ZipTools.GZipUncompress(filename, tempFilename); xDoc.Load(tempFilename); _compressedCheckpointFormat = true; } else { // Old file format is raw XML. xDoc.Load(filename); _compressedCheckpointFormat = false; } } catch { return(null); } return(xDoc); }
public void ExtractContentFromCompressedSandbox() { const string filename = @".\TestAssets\SANDBOX_0_0_0_.sbs"; const string xmlfilename = @".\TestOutput\SANDBOX_0_0_0_.xml"; ZipTools.GZipUncompress(filename, xmlfilename); }