public void SaveSectorXml(bool backupFile, XmlDocument xDoc) { var sectorFilename = Path.Combine(Savepath, SpaceEngineersConsts.SandBoxSectorFilename); if (backupFile) { var sectorBackupFilename = sectorFilename + ".bak"; if (File.Exists(sectorBackupFilename)) { FileSystem.DeleteFile(sectorBackupFilename, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } File.Move(sectorFilename, sectorBackupFilename); } if (_compressedSectorFormat) { var tempFilename = TempfileUtil.NewFilename(); xDoc.Save(tempFilename); ZipTools.GZipCompress(tempFilename, sectorFilename); } else { xDoc.Save(sectorFilename); } }
public void SaveCheckPoint(bool backupFile) { var checkpointFilename = Path.Combine(Savepath, SpaceEngineersConsts.SandBoxCheckpointFilename); if (backupFile) { var checkpointBackupFilename = checkpointFilename + ".bak"; if (File.Exists(checkpointBackupFilename)) { FileSystem.DeleteFile(checkpointBackupFilename, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } File.Move(checkpointFilename, checkpointBackupFilename); } if (_compressedCheckpointFormat) { var tempFilename = TempfileUtil.NewFilename(); SpaceEngineersApi.WriteSpaceEngineersFile(Checkpoint, tempFilename); ZipTools.GZipCompress(tempFilename, checkpointFilename); } else { SpaceEngineersApi.WriteSpaceEngineersFile(Checkpoint, checkpointFilename); } }
public void SaveSector(bool backupFile) { var sectorFilename = Path.Combine(Savepath, SpaceEngineersConsts.SandBoxSectorFilename); if (backupFile) { // xml sector file. (it may or may not be compressed) var sectorBackupFilename = sectorFilename + ".bak"; if (File.Exists(sectorBackupFilename)) { FileSystem.DeleteFile(sectorBackupFilename, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } File.Move(sectorFilename, sectorBackupFilename); // binary sector file. (it may or may not be compressed) sectorBackupFilename = sectorFilename + SpaceEngineersConsts.ProtobuffersExtension + ".bak"; if (File.Exists(sectorBackupFilename)) { FileSystem.DeleteFile(sectorBackupFilename, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } // The protoBuf .sbsPB may not exist in older save games. if (File.Exists(sectorFilename + SpaceEngineersConsts.ProtobuffersExtension)) { File.Move(sectorFilename + SpaceEngineersConsts.ProtobuffersExtension, sectorBackupFilename); } } if (_compressedSectorFormat) { var tempFilename = TempfileUtil.NewFilename(); SpaceEngineersApi.WriteSpaceEngineersFile(SectorData, tempFilename); ZipTools.GZipCompress(tempFilename, sectorFilename); } else { SpaceEngineersApi.WriteSpaceEngineersFile(SectorData, sectorFilename); } SpaceEngineersApi.WriteSpaceEngineersFilePB(SectorData, sectorFilename + SpaceEngineersConsts.ProtobuffersExtension, _compressedSectorFormat); }