[Structs] Rename Rom to File

This commit is contained in:
Matt Nadareski
2016-08-29 13:51:45 -07:00
parent 638ba055eb
commit 4d621debcf
18 changed files with 321 additions and 321 deletions

View File

@@ -18,15 +18,15 @@ namespace SabreTools.Helper
/// <param name="noSHA1">True if SHA-1 hashes should not be calcluated, false otherwise</param>
/// <returns>Populated RomData object if success, empty one on error</returns>
/// <remarks>Add read-offset for hash info</remarks>
public static Rom GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0)
public static File GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0)
{
// Add safeguard if file doesn't exist
if (!File.Exists(input))
if (!System.IO.File.Exists(input))
{
return new Rom();
return new File();
}
Rom rom = new Rom
File rom = new File
{
Name = Path.GetFileName(input),
Type = ItemType.Rom,
@@ -44,7 +44,7 @@ namespace SabreTools.Helper
using (Crc32 crc = new Crc32())
using (MD5 md5 = MD5.Create())
using (SHA1 sha1 = SHA1.Create())
using (FileStream fs = File.OpenRead(input))
using (FileStream fs = System.IO.File.OpenRead(input))
{
// Seek to the starting position, if one is set
if (offset > 0)
@@ -84,7 +84,7 @@ namespace SabreTools.Helper
}
catch (IOException)
{
return new Rom();
return new File();
}
return rom;
@@ -96,19 +96,19 @@ namespace SabreTools.Helper
/// <param name="inroms">List of RomData objects representing the roms to be merged</param>
/// <param name="logger">Logger object for console and/or file output</param>
/// <returns>A List of RomData objects representing the merged roms</returns>
public static List<Rom> Merge(List<Rom> inroms, Logger logger)
public static List<File> Merge(List<File> inroms, Logger logger)
{
// Check for null or blank roms first
if (inroms == null || inroms.Count == 0)
{
return new List<Rom>();
return new List<File>();
}
// Create output list
List<Rom> outroms = new List<Rom>();
List<File> outroms = new List<File>();
// Then deduplicate them by checking to see if data matches previous saved roms
foreach (Rom rom in inroms)
foreach (File rom in inroms)
{
// If it's a nodump, add and skip
if (rom.Nodump)
@@ -122,11 +122,11 @@ namespace SabreTools.Helper
{
// Check if the rom is a duplicate
DupeType dupetype = DupeType.None;
Rom savedrom = new Rom();
File savedrom = new File();
int pos = -1;
for (int i = 0; i < outroms.Count; i++)
{
Rom lastrom = outroms[i];
File lastrom = outroms[i];
// Get the duplicate status
dupetype = GetDuplicateStatus(rom, lastrom, logger);
@@ -194,9 +194,9 @@ namespace SabreTools.Helper
/// <param name="logger">Logger object for console and/or file output</param>
/// <param name="remove">True to remove matched roms from the input, false otherwise (default)</param>
/// <returns>List of matched RomData objects</returns>
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata, Logger logger, bool remove = false)
public static List<File> GetDuplicates(File lastrom, Dat datdata, Logger logger, bool remove = false)
{
List<Rom> output = new List<Rom>();
List<File> output = new List<File>();
// Check for an empty rom list first
if (datdata.Roms == null || datdata.Roms.Count == 0)
@@ -208,9 +208,9 @@ namespace SabreTools.Helper
List<string> keys = datdata.Roms.Keys.ToList();
foreach (string key in keys)
{
List<Rom> roms = datdata.Roms[key];
List<Rom> left = new List<Rom>();
foreach (Rom rom in roms)
List<File> roms = datdata.Roms[key];
List<File> left = new List<File>();
foreach (File rom in roms)
{
if (IsDuplicate(rom, lastrom, logger))
{
@@ -239,7 +239,7 @@ namespace SabreTools.Helper
/// <param name="lastrom">Rom to use as a baseline</param>
/// <param name="logger">Logger object for console and/or file output</param>
/// <returns>True if the roms are duplicates, false otherwise</returns>
public static bool IsDuplicate(Rom rom, Rom lastrom, Logger logger)
public static bool IsDuplicate(File rom, File lastrom, Logger logger)
{
bool dupefound = false;
@@ -274,7 +274,7 @@ namespace SabreTools.Helper
/// <param name="lastrom">Last rom to check against</param>
/// <param name="logger">Logger object for console and/or file output</param>
/// <returns>The DupeType corresponding to the relationship between the two</returns>
public static DupeType GetDuplicateStatus(Rom rom, Rom lastrom, Logger logger)
public static DupeType GetDuplicateStatus(File rom, File lastrom, Logger logger)
{
DupeType output = DupeType.None;
@@ -319,9 +319,9 @@ namespace SabreTools.Helper
/// <param name="roms">List of RomData objects representing the roms to be sorted</param>
/// <param name="norename">True if files are not renamed, false otherwise</param>
/// <returns>True if it sorted correctly, false otherwise</returns>
public static bool Sort(List<Rom> roms, bool norename)
public static bool Sort(List<File> roms, bool norename)
{
roms.Sort(delegate (Rom x, Rom y)
roms.Sort(delegate (File x, File y)
{
if (x.Metadata.SystemID == y.Metadata.SystemID)
{