コード例 #1
0
        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);
                        }
                    }
                }
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 public void AutoSave()
 {
     SafeSaveHelper.SaveGame(RootPath, SafeSaveHelper.AddFileExtension(AutoSaveFileNamePrefix, FileExtension), MaximumAutoSaveCount, OnSaveRequested);
 }
コード例 #4
0
 public void LoadGame(string fileNameWithoutExtension, bool forceRevert = false)
 {
     SafeSaveHelper.LoadGame(RootPath, SafeSaveHelper.AddFileExtension(fileNameWithoutExtension, FileExtension), forceRevert, OnLoadRequested);
 }
コード例 #5
0
 public void SaveGame(string fileNameWithoutExtension)
 {
     SafeSaveHelper.SaveGame(RootPath, SafeSaveHelper.AddFileExtension(fileNameWithoutExtension, FileExtension), MaximumSafeSaveCount, OnSaveRequested);
 }