Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor equality check in MDS_Format.MountBlobs #4228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ public static LoadResults LoadMDSPath(string path)
/// <exception cref="MDSParseException">path reference no longer points to file</exception>
private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
{
Debug.Assert(disc.DisposableResources.Count is 0, "no other method should be adding to DisposableResources");
var BlobIndex = new Dictionary<int, IBlob>();

var count = 0;
Expand All @@ -667,18 +668,11 @@ private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
if (!File.Exists(file))
throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}");

//mount the file
var mdfBlob = new Blob_RawFile { PhysicalPath = file };

var dupe = false;
foreach (var re in disc.DisposableResources)
{
if (re.ToString() == mdfBlob.ToString())
dupe = true;
}

if (!dupe)
//mount the file
if (!disc.DisposableResources.Cast<Blob_RawFile>()
.Select(static re => re.PhysicalPath).Contains(file))
{
Blob_RawFile mdfBlob = new() { PhysicalPath = file };
// wrap in zeropadadapter
disc.DisposableResources.Add(mdfBlob);
BlobIndex[count++] = mdfBlob;
Expand Down