do the todo of renaming BinaryStateSaver/Loader to ZipStateSaver/Loader

This commit is contained in:
adelikat 2020-05-31 10:28:02 -05:00
parent d21c5dfdfa
commit a0680e4b94
6 changed files with 16 additions and 19 deletions

View File

@ -15,7 +15,7 @@ namespace BizHawk.Client.Common
// the old method of text savestate save is now gone.
// a text savestate is just like a binary savestate, but with a different core lump
using var bs = new BinaryStateSaver(filename, Global.Config.SaveStateCompressionLevelNormal);
using var bs = new ZipStateSaver(filename, Global.Config.SaveStateCompressionLevelNormal);
bs.PutVersionLumps();
if (Global.Config.SaveStateType == SaveStateTypeE.Text)
{
@ -101,7 +101,7 @@ namespace BizHawk.Client.Common
var core = emulator.AsStatable();
// try to detect binary first
var bl = BinaryStateLoader.LoadAndDetect(path);
var bl = ZipStateLoader.LoadAndDetect(path);
if (bl != null)
{
try

View File

@ -42,7 +42,7 @@ namespace BizHawk.Client.Common
return false;
}
using (var bl = BinaryStateLoader.LoadAndDetect(Filename, true))
using (var bl = ZipStateLoader.LoadAndDetect(Filename, true))
{
if (bl == null)
{
@ -184,7 +184,7 @@ namespace BizHawk.Client.Common
Directory.CreateDirectory(file.Directory.ToString());
}
using var bs = new BinaryStateSaver(fn, Global.Config.MovieCompressionLevel);
using var bs = new ZipStateSaver(fn, Global.Config.MovieCompressionLevel);
bs.PutLump(BinaryStateLump.Movieheader, tw => tw.WriteLine(Header.ToString()));
bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));

View File

@ -31,8 +31,8 @@ namespace BizHawk.Client.Common
void Swap(int b1, int b2);
void Replace(TasBranch old, TasBranch newBranch);
void Save(BinaryStateSaver bs);
void Load(BinaryStateLoader bl, ITasMovie movie);
void Save(ZipStateSaver bs);
void Load(ZipStateLoader bl, ITasMovie movie);
}
public class TasBranchCollection : List<TasBranch>, ITasBranchCollection
@ -108,7 +108,7 @@ namespace BizHawk.Client.Common
return result;
}
public void Save(BinaryStateSaver bs)
public void Save(ZipStateSaver bs)
{
var nheader = new IndexedStateLump(BinaryStateLump.BranchHeader);
var ncore = new IndexedStateLump(BinaryStateLump.BranchCoreData);
@ -176,7 +176,7 @@ namespace BizHawk.Client.Common
}
}
public void Load(BinaryStateLoader bl, ITasMovie movie)
public void Load(ZipStateLoader bl, ITasMovie movie)
{
var nheader = new IndexedStateLump(BinaryStateLump.BranchHeader);
var ncore = new IndexedStateLump(BinaryStateLump.BranchCoreData);

View File

@ -18,7 +18,7 @@ namespace BizHawk.Client.Common
Directory.CreateDirectory(file.Directory.ToString());
}
using var bs = new BinaryStateSaver(fn, Global.Config.MovieCompressionLevel);
using var bs = new ZipStateSaver(fn, Global.Config.MovieCompressionLevel);
bs.PutLump(BinaryStateLump.Movieheader, tw => tw.WriteLine(Header.ToString()));
bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
@ -85,7 +85,7 @@ namespace BizHawk.Client.Common
return false;
}
using (var bl = BinaryStateLoader.LoadAndDetect(Filename, true))
using (var bl = ZipStateLoader.LoadAndDetect(Filename, true))
{
if (bl == null)
{

View File

@ -6,17 +6,14 @@ using ICSharpCode.SharpZipLib.Zip;
namespace BizHawk.Client.Common
{
/// <summary>
/// more accurately should be called ZipStateLoader, as it supports both text and binary core data
/// </summary>
public class BinaryStateLoader : IDisposable
public class ZipStateLoader : IDisposable
{
private ZipFile _zip;
private Version _ver;
private bool _isDisposed;
private Dictionary<string, ZipEntry> _entriesByName;
private BinaryStateLoader()
private ZipStateLoader()
{
}
@ -71,9 +68,9 @@ namespace BizHawk.Client.Common
}
private static readonly byte[] Zipheader = { 0x50, 0x4b, 0x03, 0x04 };
public static BinaryStateLoader LoadAndDetect(string filename, bool isMovieLoad = false)
public static ZipStateLoader LoadAndDetect(string filename, bool isMovieLoad = false)
{
var ret = new BinaryStateLoader();
var ret = new ZipStateLoader();
using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
{

View File

@ -3,7 +3,7 @@ using System.IO;
namespace BizHawk.Client.Common
{
public class BinaryStateSaver : IDisposable
public class ZipStateSaver : IDisposable
{
private readonly IZipWriter _zip;
private bool _isDisposed;
@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
sw.Flush();
}
public BinaryStateSaver(string path, int compressionLevel)
public ZipStateSaver(string path, int compressionLevel)
{
_zip = new FrameworkZipWriter(path, compressionLevel);
}