Emulation.DiscSystem - cleanup - use extension method, using declarations

This commit is contained in:
adelikat 2020-02-26 14:53:36 -06:00
parent 3f9b93be59
commit 4cf29c5169
5 changed files with 66 additions and 76 deletions

View File

@ -19,11 +19,9 @@ namespace BizHawk.Emulation.DiscSystem
public void WriteFile(string fname)
{
using (FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write, FileShare.Read))
{
using FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write, FileShare.Read);
WriteStream(fs);
}
}
public Stream BaseStream;

View File

@ -423,10 +423,8 @@ namespace BizHawk.Emulation.DiscSystem
var buf2448 = new byte[2448];
DiscSectorReader dsr = new DiscSectorReader(disc);
using (var imgFile = File.OpenWrite(imgPath))
using (var subFile = File.OpenWrite(subPath))
{
using var imgFile = File.OpenWrite(imgPath);
using var subFile = File.OpenWrite(subPath);
int nLBA = disc.Session1.LeadoutLBA;
for (int lba = 0; lba < nLBA; lba++)
{
@ -436,8 +434,6 @@ namespace BizHawk.Emulation.DiscSystem
}
}
}
class SS_CCD : ISectorSynthJob2448
{
public void Synth(SectorSynthJob job)

View File

@ -251,8 +251,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
//TODO - fix exception-throwing inside
//TODO - verify stream-disposing semantics
var fs = File.OpenRead(choice);
using (var blob = new Disc.Blob_WaveFile())
{
using var blob = new Disc.Blob_WaveFile();
try
{
blob.Load(fs);
@ -263,7 +262,6 @@ namespace BizHawk.Emulation.DiscSystem.CUE
cfi.Type = CompiledCueFileType.DecodeAudio;
}
}
}
else if (blobPathExt == ".APE") cfi.Type = CompiledCueFileType.DecodeAudio;
else if (blobPathExt == ".MP3") cfi.Type = CompiledCueFileType.DecodeAudio;
else if (blobPathExt == ".MPC") cfi.Type = CompiledCueFileType.DecodeAudio;

View File

@ -357,10 +357,10 @@ namespace BizHawk.Emulation.DiscSystem
{
var data = ReadSectorCached(lba);
if (data == null) return false;
byte[] cmp = System.Text.Encoding.ASCII.GetBytes(s);
byte[] cmp = Encoding.ASCII.GetBytes(s);
byte[] cmp2 = new byte[cmp.Length];
Buffer.BlockCopy(data, n, cmp2, 0, cmp.Length);
return System.Linq.Enumerable.SequenceEqual(cmp, cmp2);
return cmp.SequenceEqual(cmp2);
}
private bool SectorContains(string s, int lba = 0)

View File

@ -23,8 +23,7 @@ namespace BizHawk.Emulation.DiscSystem.SBI
/// <exception cref="SBIParseException">file at <see cref="IN_Path"/> does not contain valid header or contains misformatted record</exception>
public void Run()
{
using (var fs = File.OpenRead(IN_Path))
{
using var fs = File.OpenRead(IN_Path);
BinaryReader br = new BinaryReader(fs);
string sig = br.ReadStringFixedAscii(4);
if (sig != "SBI\0")
@ -76,5 +75,4 @@ namespace BizHawk.Emulation.DiscSystem.SBI
OUT_Data = ret;
}
}
}
}