public void Import(string importFileName) { using (var streamReader = File.OpenRead(importFileName)) { var zipFile = new ZipFile(streamReader); foreach (ZipEntry entry in zipFile) { if (!entry.IsFile) { continue; } var entryName = entry.Name; var buffer = new byte[4096]; using (var inputStream = zipFile.GetInputStream(entry)) { var fullZipToPath = Path.Combine(RootPath, SafeSaveHelper.GetIncrementalFileName(entry.Name, 1)); var directoryName = Path.GetDirectoryName(fullZipToPath); if (directoryName.Length > 0) { Directory.CreateDirectory(directoryName); } using (var streamWriter = File.Create(fullZipToPath)) { ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(inputStream, streamWriter, buffer); } } } } }
private void CleanseSaveByBaseName(string baseFileName) { var directoryInfo = new DirectoryInfo(RootPath); var files = (from file in directoryInfo.EnumerateFiles(SafeSaveHelper.GetSearchPatternFromFileName(baseFileName)) select file).ToArray(); foreach (var file in files) { file.Delete(); } }
public void AutoSave() { SafeSaveHelper.SaveGame(RootPath, SafeSaveHelper.AddFileExtension(AutoSaveFileNamePrefix, FileExtension), MaximumAutoSaveCount, OnSaveRequested); }
public void LoadGame(string fileNameWithoutExtension, bool forceRevert = false) { SafeSaveHelper.LoadGame(RootPath, SafeSaveHelper.AddFileExtension(fileNameWithoutExtension, FileExtension), forceRevert, OnLoadRequested); }
public void SaveGame(string fileNameWithoutExtension) { SafeSaveHelper.SaveGame(RootPath, SafeSaveHelper.AddFileExtension(fileNameWithoutExtension, FileExtension), MaximumSafeSaveCount, OnSaveRequested); }