コード例 #1
0
 public static SavegameFile Read(
     string path,
     IReadSavegameProgress progress = null)
 {
     if (progress != null)
     {
         progress.Report(true, true, 0, 0);
     }
     using (var compressedInputStream = File.OpenRead(path))
         using (var inputStream = ChunkedLz4File.Decompress(compressedInputStream))
             using (var reader = new BinaryReader(inputStream, Encoding.ASCII, true))
             {
                 var savegameFile = new SavegameFile();
                 savegameFile.ReadHeader(reader);
                 savegameFile.ReadFooter(reader);
                 savegameFile.ReadStringTable(reader);
                 savegameFile.ReadVariableTable(reader);
                 if (progress != null)
                 {
                     progress.Report(true, false, 0, savegameFile.VariableTableEntries.Length);
                 }
                 savegameFile.ReadVariables(reader, progress);
                 savegameFile.ReferenceVariable(reader, progress);
                 if (progress != null)
                 {
                     progress.Report(false, false, 0, 0);
                 }
                 return(savegameFile);
             }
 }
コード例 #2
0
 public void dumpfile(string filename)
 {
     using (FileStream compressedStream = File.OpenRead(filename))
         using (Stream decompressedStream = ChunkedLz4File.Decompress(compressedStream))
             using (FileStream outputstream = File.OpenWrite(filename.Substring(0, filename.Length - 4) + "decomp.sav"))
             {
                 decompressedStream.CopyTo(outputstream);
             }
 }