mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Simplify copying external information
This commit is contained in:
@@ -148,6 +148,24 @@ namespace SabreTools.FileTypes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copy all missing information from one BaseFile to another
|
||||||
|
/// </summary>
|
||||||
|
private static void CopyInformation(BaseFile from, BaseFile to)
|
||||||
|
{
|
||||||
|
to.Filename ??= from.Filename;
|
||||||
|
to.Parent ??= from.Parent;
|
||||||
|
to.Date ??= from.Date;
|
||||||
|
to.Size ??= from.Size;
|
||||||
|
to.CRC ??= from.CRC;
|
||||||
|
to.MD5 ??= from.MD5;
|
||||||
|
to.SHA1 ??= from.SHA1;
|
||||||
|
to.SHA256 ??= from.SHA256;
|
||||||
|
to.SHA384 ??= from.SHA384;
|
||||||
|
to.SHA512 ??= from.SHA512;
|
||||||
|
to.SpamSum ??= from.SpamSum;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the correct base file based on the type and filter options
|
/// Get the correct base file based on the type and filter options
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -162,18 +180,7 @@ namespace SabreTools.FileTypes
|
|||||||
AaruFormat? aif = AaruFormat.Create(inputStream);
|
AaruFormat? aif = AaruFormat.Create(inputStream);
|
||||||
if (aif != null)
|
if (aif != null)
|
||||||
{
|
{
|
||||||
aif.Filename = baseFile.Filename;
|
CopyInformation(baseFile, aif);
|
||||||
aif.Parent = baseFile.Parent;
|
|
||||||
aif.Date = baseFile.Date;
|
|
||||||
aif.Size = baseFile.Size;
|
|
||||||
aif.CRC = baseFile.CRC;
|
|
||||||
aif.MD5 = baseFile.MD5;
|
|
||||||
aif.SHA1 = baseFile.SHA1;
|
|
||||||
aif.SHA256 = baseFile.SHA256;
|
|
||||||
aif.SHA384 = baseFile.SHA384;
|
|
||||||
aif.SHA512 = baseFile.SHA512;
|
|
||||||
aif.SpamSum = baseFile.SpamSum;
|
|
||||||
|
|
||||||
return aif;
|
return aif;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,18 +189,7 @@ namespace SabreTools.FileTypes
|
|||||||
CHDFile? chd = CHDFile.Create(inputStream);
|
CHDFile? chd = CHDFile.Create(inputStream);
|
||||||
if (chd != null)
|
if (chd != null)
|
||||||
{
|
{
|
||||||
chd.Filename = baseFile.Filename;
|
CopyInformation(baseFile, chd);
|
||||||
chd.Parent = baseFile.Parent;
|
|
||||||
chd.Date = baseFile.Date;
|
|
||||||
chd.Size = baseFile.Size;
|
|
||||||
chd.CRC = baseFile.CRC;
|
|
||||||
chd.MD5 = baseFile.MD5;
|
|
||||||
chd.SHA1 = baseFile.SHA1;
|
|
||||||
chd.SHA256 = baseFile.SHA256;
|
|
||||||
chd.SHA384 = baseFile.SHA384;
|
|
||||||
chd.SHA512 = baseFile.SHA512;
|
|
||||||
chd.SpamSum = baseFile.SpamSum;
|
|
||||||
|
|
||||||
return chd;
|
return chd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user