mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Rename File to Rom again
I'm reverting this because there might be cases where System.IO.File and SabreTools.Helper.File could be in conflict
This commit is contained in:
@@ -254,7 +254,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now add the information to the database if it's not already there
|
// Now add the information to the database if it's not already there
|
||||||
Helper.File rom = RomTools.GetSingleFileInfo(newfile);
|
Helper.Rom rom = RomTools.GetSingleFileInfo(newfile);
|
||||||
AddHeaderToDatabase(hstr, rom.HashData.SHA1, type);
|
AddHeaderToDatabase(hstr, rom.HashData.SHA1, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ namespace SabreTools
|
|||||||
public bool ReplaceHeader(string file)
|
public bool ReplaceHeader(string file)
|
||||||
{
|
{
|
||||||
// First, get the SHA-1 hash of the file
|
// First, get the SHA-1 hash of the file
|
||||||
Helper.File rom = RomTools.GetSingleFileInfo(file);
|
Helper.Rom rom = RomTools.GetSingleFileInfo(file);
|
||||||
|
|
||||||
// Then try to pull the corresponding headers from the database
|
// Then try to pull the corresponding headers from the database
|
||||||
string header = "";
|
string header = "";
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace SabreTools.Helper
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intermediate struct for holding and processing rom data
|
/// Intermediate struct for holding and processing rom data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct File : IComparable, IEquatable<File>
|
public struct Rom : IComparable, IEquatable<Rom>
|
||||||
{
|
{
|
||||||
public Machine Machine;
|
public Machine Machine;
|
||||||
public string Name;
|
public string Name;
|
||||||
@@ -64,7 +64,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File comp = (File)obj;
|
Rom comp = (Rom)obj;
|
||||||
|
|
||||||
if (this.Machine.Name == comp.Machine.Name)
|
if (this.Machine.Name == comp.Machine.Name)
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ namespace SabreTools.Helper
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(File other)
|
public bool Equals(Rom other)
|
||||||
{
|
{
|
||||||
Logger temp = new Logger(false, "");
|
Logger temp = new Logger(false, "");
|
||||||
temp.Start();
|
temp.Start();
|
||||||
@@ -153,7 +153,7 @@ namespace SabreTools.Helper
|
|||||||
public ForcePacking ForcePacking;
|
public ForcePacking ForcePacking;
|
||||||
public OutputFormat OutputFormat;
|
public OutputFormat OutputFormat;
|
||||||
public bool MergeRoms;
|
public bool MergeRoms;
|
||||||
public Dictionary<string, List<File>> Files;
|
public Dictionary<string, List<Rom>> Files;
|
||||||
|
|
||||||
// Data specific to the Miss DAT type
|
// Data specific to the Miss DAT type
|
||||||
public bool UseGame;
|
public bool UseGame;
|
||||||
@@ -241,7 +241,7 @@ namespace SabreTools.Helper
|
|||||||
ForcePacking = this.ForcePacking,
|
ForcePacking = this.ForcePacking,
|
||||||
OutputFormat = this.OutputFormat,
|
OutputFormat = this.OutputFormat,
|
||||||
MergeRoms = this.MergeRoms,
|
MergeRoms = this.MergeRoms,
|
||||||
Files = new Dictionary<string, List<File>>(),
|
Files = new Dictionary<string, List<Rom>>(),
|
||||||
UseGame = this.UseGame,
|
UseGame = this.UseGame,
|
||||||
Prefix = this.Prefix,
|
Prefix = this.Prefix,
|
||||||
Postfix = this.Postfix,
|
Postfix = this.Postfix,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="input">Input filename to be moved</param>
|
/// <param name="input">Input filename to be moved</param>
|
||||||
/// <param name="output">Output directory to build to</param>
|
/// <param name="output">Output directory to build to</param>
|
||||||
/// <param name="rom">RomData representing the new information</param>
|
/// <param name="rom">RomData representing the new information</param>
|
||||||
public static void WriteToArchive(string input, string output, File rom)
|
public static void WriteToArchive(string input, string output, Rom rom)
|
||||||
{
|
{
|
||||||
string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
|
string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="input">Input filename to be moved</param>
|
/// <param name="input">Input filename to be moved</param>
|
||||||
/// <param name="output">Output directory to build to</param>
|
/// <param name="output">Output directory to build to</param>
|
||||||
/// <param name="rom">RomData representing the new information</param>
|
/// <param name="rom">RomData representing the new information</param>
|
||||||
public static void WriteToManagedArchive(string input, string output, File rom)
|
public static void WriteToManagedArchive(string input, string output, Rom rom)
|
||||||
{
|
{
|
||||||
string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
|
string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
|
||||||
|
|
||||||
@@ -474,9 +474,9 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="input">Input file to get data from</param>
|
/// <param name="input">Input file to get data from</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <returns>List of RomData objects representing the found data</returns>
|
/// <returns>List of RomData objects representing the found data</returns>
|
||||||
public static List<File> GetArchiveFileInfo(string input, Logger logger)
|
public static List<Rom> GetArchiveFileInfo(string input, Logger logger)
|
||||||
{
|
{
|
||||||
List<File> roms = new List<File>();
|
List<Rom> roms = new List<Rom>();
|
||||||
string gamename = Path.GetFileNameWithoutExtension(input);
|
string gamename = Path.GetFileNameWithoutExtension(input);
|
||||||
|
|
||||||
// First get the archive type
|
// First get the archive type
|
||||||
@@ -491,7 +491,7 @@ namespace SabreTools.Helper
|
|||||||
// If we got back GZip, try to get TGZ info first
|
// If we got back GZip, try to get TGZ info first
|
||||||
else if (at == ArchiveType.GZip)
|
else if (at == ArchiveType.GZip)
|
||||||
{
|
{
|
||||||
File possibleTgz = GetTorrentGZFileInfo(input, logger);
|
Rom possibleTgz = GetTorrentGZFileInfo(input, logger);
|
||||||
|
|
||||||
// If it was, then add it to the outputs and continue
|
// If it was, then add it to the outputs and continue
|
||||||
if (possibleTgz.Name != null)
|
if (possibleTgz.Name != null)
|
||||||
@@ -534,7 +534,7 @@ namespace SabreTools.Helper
|
|||||||
+ (size == 0 ? reader.Entry.Size : size) + ", "
|
+ (size == 0 ? reader.Entry.Size : size) + ", "
|
||||||
+ (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
+ (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||||
|
|
||||||
roms.Add(new File
|
roms.Add(new Rom
|
||||||
{
|
{
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
Name = reader.Entry.Key,
|
Name = reader.Entry.Key,
|
||||||
@@ -570,7 +570,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="input">Filename to get information from</param>
|
/// <param name="input">Filename to get information from</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <returns>Populated RomData object if success, empty one on error</returns>
|
/// <returns>Populated RomData object if success, empty one on error</returns>
|
||||||
public static File GetTorrentGZFileInfo(string input, Logger logger)
|
public static Rom GetTorrentGZFileInfo(string input, Logger logger)
|
||||||
{
|
{
|
||||||
string datum = Path.GetFileName(input).ToLowerInvariant();
|
string datum = Path.GetFileName(input).ToLowerInvariant();
|
||||||
long filesize = new FileInfo(input).Length;
|
long filesize = new FileInfo(input).Length;
|
||||||
@@ -579,14 +579,14 @@ namespace SabreTools.Helper
|
|||||||
if (!Regex.IsMatch(datum, @"^[0-9a-f]{40}\.gz"))
|
if (!Regex.IsMatch(datum, @"^[0-9a-f]{40}\.gz"))
|
||||||
{
|
{
|
||||||
logger.Warning("Non SHA-1 filename found, skipping: '" + datum + "'");
|
logger.Warning("Non SHA-1 filename found, skipping: '" + datum + "'");
|
||||||
return new File();
|
return new Rom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the file is at least the minimum length
|
// Check if the file is at least the minimum length
|
||||||
if (filesize < 40 /* bytes */)
|
if (filesize < 40 /* bytes */)
|
||||||
{
|
{
|
||||||
logger.Warning("Possibly corrupt file '" + input + "' with size " + Style.GetBytesReadable(filesize));
|
logger.Warning("Possibly corrupt file '" + input + "' with size " + Style.GetBytesReadable(filesize));
|
||||||
return new File();
|
return new Rom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Romba-specific header data
|
// Get the Romba-specific header data
|
||||||
@@ -610,7 +610,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
if (!correct)
|
if (!correct)
|
||||||
{
|
{
|
||||||
return new File();
|
return new Rom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now convert the data and get the right position
|
// Now convert the data and get the right position
|
||||||
@@ -618,7 +618,7 @@ namespace SabreTools.Helper
|
|||||||
string gzcrc = BitConverter.ToString(headercrc).Replace("-", string.Empty);
|
string gzcrc = BitConverter.ToString(headercrc).Replace("-", string.Empty);
|
||||||
long extractedsize = (long)BitConverter.ToUInt64(headersz.Reverse().ToArray(), 0);
|
long extractedsize = (long)BitConverter.ToUInt64(headersz.Reverse().ToArray(), 0);
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
@@ -665,7 +665,7 @@ namespace SabreTools.Helper
|
|||||||
outdir = Path.GetFullPath(outdir);
|
outdir = Path.GetFullPath(outdir);
|
||||||
|
|
||||||
// Now get the Rom info for the file so we have hashes and size
|
// Now get the Rom info for the file so we have hashes and size
|
||||||
File rom = RomTools.GetSingleFileInfo(input);
|
Rom rom = RomTools.GetSingleFileInfo(input);
|
||||||
|
|
||||||
// If it doesn't exist, create the output file and then write
|
// If it doesn't exist, create the output file and then write
|
||||||
string outfile = Path.Combine(outdir, rom.HashData.SHA1 + ".gz");
|
string outfile = Path.Combine(outdir, rom.HashData.SHA1 + ".gz");
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace SabreTools.Helper
|
|||||||
// Make sure there's a dictionary to read to
|
// Make sure there's a dictionary to read to
|
||||||
if (datdata.Files == null)
|
if (datdata.Files == null)
|
||||||
{
|
{
|
||||||
datdata.Files = new Dictionary<string, List<File>>();
|
datdata.Files = new Dictionary<string, List<Rom>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now parse the correct type of DAT
|
// Now parse the correct type of DAT
|
||||||
@@ -170,7 +170,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in cleaning mode, sanitize the game name
|
// If we're in cleaning mode, sanitize the game name
|
||||||
gamename = (clean ? Style.CleanGameName(gamename) : gamename);
|
gamename = (clean ? Style.CleanGameName(gamename) : gamename);
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
{
|
{
|
||||||
@@ -328,7 +328,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> templist = new List<File>();
|
List<Rom> templist = new List<Rom>();
|
||||||
templist.Add(rom);
|
templist.Add(rom);
|
||||||
datdata.Files.Add(key, templist);
|
datdata.Files.Add(key, templist);
|
||||||
}
|
}
|
||||||
@@ -566,7 +566,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in cleaning mode, sanitize the game name
|
// If we're in cleaning mode, sanitize the game name
|
||||||
rominfo[3] = (clean ? Style.CleanGameName(rominfo[3]) : rominfo[3]);
|
rominfo[3] = (clean ? Style.CleanGameName(rominfo[3]) : rominfo[3]);
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
{
|
{
|
||||||
@@ -616,7 +616,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> templist = new List<File>();
|
List<Rom> templist = new List<Rom>();
|
||||||
templist.Add(rom);
|
templist.Add(rom);
|
||||||
datdata.Files.Add(key, templist);
|
datdata.Files.Add(key, templist);
|
||||||
}
|
}
|
||||||
@@ -677,7 +677,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in cleaning mode, sanitize the game name
|
// If we're in cleaning mode, sanitize the game name
|
||||||
tempgame = (clean ? Style.CleanGameName(tempgame) : tempgame);
|
tempgame = (clean ? Style.CleanGameName(tempgame) : tempgame);
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
Name = "null",
|
Name = "null",
|
||||||
@@ -702,7 +702,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> temp = new List<File>();
|
List<Rom> temp = new List<Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
datdata.Files.Add(key, temp);
|
datdata.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -1081,7 +1081,7 @@ namespace SabreTools.Helper
|
|||||||
if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore")
|
if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore")
|
||||||
{
|
{
|
||||||
int index = datdata.Files[key].Count() - 1;
|
int index = datdata.Files[key].Count() - 1;
|
||||||
File lastrom = datdata.Files[key][index];
|
Rom lastrom = datdata.Files[key][index];
|
||||||
lastrom.HashData.Size += size;
|
lastrom.HashData.Size += size;
|
||||||
datdata.Files[key].RemoveAt(index);
|
datdata.Files[key].RemoveAt(index);
|
||||||
datdata.Files[key].Add(lastrom);
|
datdata.Files[key].Add(lastrom);
|
||||||
@@ -1127,7 +1127,7 @@ namespace SabreTools.Helper
|
|||||||
// Get the new values to add
|
// Get the new values to add
|
||||||
key = size + "-" + crc;
|
key = size + "-" + crc;
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
{
|
{
|
||||||
@@ -1154,7 +1154,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> newvalue = new List<File>();
|
List<Rom> newvalue = new List<Rom>();
|
||||||
newvalue.Add(rom);
|
newvalue.Add(rom);
|
||||||
datdata.Files.Add(key, newvalue);
|
datdata.Files.Add(key, newvalue);
|
||||||
}
|
}
|
||||||
@@ -1186,7 +1186,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in cleaning mode, sanitize the game name
|
// If we're in cleaning mode, sanitize the game name
|
||||||
tempname = (clean ? Style.CleanGameName(tempname.Split(Path.DirectorySeparatorChar)) : tempname);
|
tempname = (clean ? Style.CleanGameName(tempname.Split(Path.DirectorySeparatorChar)) : tempname);
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
Name = "null",
|
Name = "null",
|
||||||
@@ -1211,7 +1211,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> temp = new List<File>();
|
List<Rom> temp = new List<Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
datdata.Files.Add(key, temp);
|
datdata.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -1312,7 +1312,7 @@ namespace SabreTools.Helper
|
|||||||
if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore")
|
if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore")
|
||||||
{
|
{
|
||||||
int index = datdata.Files[key].Count() - 1;
|
int index = datdata.Files[key].Count() - 1;
|
||||||
File lastrom = datdata.Files[key][index];
|
Rom lastrom = datdata.Files[key][index];
|
||||||
lastrom.HashData.Size += size;
|
lastrom.HashData.Size += size;
|
||||||
datdata.Files[key].RemoveAt(index);
|
datdata.Files[key].RemoveAt(index);
|
||||||
datdata.Files[key].Add(lastrom);
|
datdata.Files[key].Add(lastrom);
|
||||||
@@ -1367,7 +1367,7 @@ namespace SabreTools.Helper
|
|||||||
// Get the new values to add
|
// Get the new values to add
|
||||||
key = size + "-" + crc;
|
key = size + "-" + crc;
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
{
|
{
|
||||||
@@ -1393,7 +1393,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> newvalue = new List<File>();
|
List<Rom> newvalue = new List<Rom>();
|
||||||
newvalue.Add(rom);
|
newvalue.Add(rom);
|
||||||
datdata.Files.Add(key, newvalue);
|
datdata.Files.Add(key, newvalue);
|
||||||
}
|
}
|
||||||
@@ -1431,9 +1431,9 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
/// <returns>SortedDictionary bucketed by game name</returns>
|
/// <returns>SortedDictionary bucketed by game name</returns>
|
||||||
public static SortedDictionary<string, List<File>> BucketByGame(List<File> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
public static SortedDictionary<string, List<Rom>> BucketByGame(List<Rom> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||||
{
|
{
|
||||||
Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
|
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||||
dict.Add("key", list);
|
dict.Add("key", list);
|
||||||
return BucketByGame(dict, mergeroms, norename, logger, output);
|
return BucketByGame(dict, mergeroms, norename, logger, output);
|
||||||
}
|
}
|
||||||
@@ -1447,9 +1447,9 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
/// <returns>SortedDictionary bucketed by game name</returns>
|
/// <returns>SortedDictionary bucketed by game name</returns>
|
||||||
public static SortedDictionary<string, List<File>> BucketByGame(IDictionary<string, List<File>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
public static SortedDictionary<string, List<Rom>> BucketByGame(IDictionary<string, List<Rom>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||||
{
|
{
|
||||||
SortedDictionary<string, List<File>> sortable = new SortedDictionary<string, List<File>>();
|
SortedDictionary<string, List<Rom>> sortable = new SortedDictionary<string, List<Rom>>();
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
// If we have a null dict or an empty one, output a new dictionary
|
// If we have a null dict or an empty one, output a new dictionary
|
||||||
@@ -1461,13 +1461,13 @@ namespace SabreTools.Helper
|
|||||||
// Process each all of the roms
|
// Process each all of the roms
|
||||||
foreach (string key in dict.Keys)
|
foreach (string key in dict.Keys)
|
||||||
{
|
{
|
||||||
List<File> roms = dict[key];
|
List<Rom> roms = dict[key];
|
||||||
if (mergeroms)
|
if (mergeroms)
|
||||||
{
|
{
|
||||||
roms = RomTools.Merge(roms, logger);
|
roms = RomTools.Merge(roms, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (File rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
string newkey = (norename ? ""
|
string newkey = (norename ? ""
|
||||||
@@ -1483,7 +1483,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> temp = new List<File>();
|
List<Rom> temp = new List<Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
sortable.Add(newkey, temp);
|
sortable.Add(newkey, temp);
|
||||||
}
|
}
|
||||||
@@ -1508,9 +1508,9 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
/// <returns>SortedDictionary bucketed by size and hash</returns>
|
/// <returns>SortedDictionary bucketed by size and hash</returns>
|
||||||
public static SortedDictionary<string, List<File>> BucketByHashSize(List<File> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
public static SortedDictionary<string, List<Rom>> BucketByHashSize(List<Rom> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||||
{
|
{
|
||||||
Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
|
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||||
dict.Add("key", list);
|
dict.Add("key", list);
|
||||||
return BucketByHashSize(dict, mergeroms, norename, logger, output);
|
return BucketByHashSize(dict, mergeroms, norename, logger, output);
|
||||||
}
|
}
|
||||||
@@ -1524,9 +1524,9 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
/// <returns>SortedDictionary bucketed by size and hash</returns>
|
/// <returns>SortedDictionary bucketed by size and hash</returns>
|
||||||
public static SortedDictionary<string, List<File>> BucketByHashSize(IDictionary<string, List<File>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
public static SortedDictionary<string, List<Rom>> BucketByHashSize(IDictionary<string, List<Rom>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||||
{
|
{
|
||||||
SortedDictionary<string, List<File>> sortable = new SortedDictionary<string, List<File>>();
|
SortedDictionary<string, List<Rom>> sortable = new SortedDictionary<string, List<Rom>>();
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
// If we have a null dict or an empty one, output a new dictionary
|
// If we have a null dict or an empty one, output a new dictionary
|
||||||
@@ -1536,15 +1536,15 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process each all of the roms
|
// Process each all of the roms
|
||||||
foreach (List<File> roms in dict.Values)
|
foreach (List<Rom> roms in dict.Values)
|
||||||
{
|
{
|
||||||
List<File> newroms = roms;
|
List<Rom> newroms = roms;
|
||||||
if (mergeroms)
|
if (mergeroms)
|
||||||
{
|
{
|
||||||
newroms = RomTools.Merge(newroms, logger);
|
newroms = RomTools.Merge(newroms, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (File rom in newroms)
|
foreach (Rom rom in newroms)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
||||||
@@ -1554,7 +1554,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> temp = new List<File>();
|
List<Rom> temp = new List<Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
sortable.Add(key, temp);
|
sortable.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -1756,7 +1756,7 @@ namespace SabreTools.Helper
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
userData = new Dat
|
userData = new Dat
|
||||||
{
|
{
|
||||||
Files = new Dictionary<string, List<File>>(),
|
Files = new Dictionary<string, List<Rom>>(),
|
||||||
MergeRoms = inputDat.MergeRoms,
|
MergeRoms = inputDat.MergeRoms,
|
||||||
};
|
};
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
@@ -1771,14 +1771,14 @@ namespace SabreTools.Helper
|
|||||||
datHeaders.Add((Dat)userData.CloneHeader());
|
datHeaders.Add((Dat)userData.CloneHeader());
|
||||||
|
|
||||||
// Reset the header values so the next can be captured
|
// Reset the header values so the next can be captured
|
||||||
Dictionary<string, List<File>> temp = userData.Files;
|
Dictionary<string, List<Rom>> temp = userData.Files;
|
||||||
userData = new Dat();
|
userData = new Dat();
|
||||||
userData.Files = temp;
|
userData.Files = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the output values
|
// Set the output values
|
||||||
Dictionary<string, List<File>> roms = userData.Files;
|
Dictionary<string, List<Rom>> roms = userData.Files;
|
||||||
userData = (Dat)inputDat.CloneHeader();
|
userData = (Dat)inputDat.CloneHeader();
|
||||||
userData.Files = roms;
|
userData.Files = roms;
|
||||||
|
|
||||||
@@ -1810,14 +1810,14 @@ namespace SabreTools.Helper
|
|||||||
long slt, long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, Logger logger)
|
long slt, long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, Logger logger)
|
||||||
{
|
{
|
||||||
// Now loop through and create a new Rom dictionary using filtered values
|
// Now loop through and create a new Rom dictionary using filtered values
|
||||||
Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
|
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||||
List<string> keys = datdata.Files.Keys.ToList();
|
List<string> keys = datdata.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<File> roms = datdata.Files[key];
|
List<Rom> roms = datdata.Files[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
File rom = roms[i];
|
Rom rom = roms[i];
|
||||||
|
|
||||||
// Filter on nodump status
|
// Filter on nodump status
|
||||||
if (nodump == true && !rom.Nodump)
|
if (nodump == true && !rom.Nodump)
|
||||||
@@ -1963,7 +1963,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> temp = new List<File>();
|
List<Rom> temp = new List<Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
dict.Add(key, temp);
|
dict.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -2041,11 +2041,11 @@ namespace SabreTools.Helper
|
|||||||
List<string> keys = userData.Files.Keys.ToList();
|
List<string> keys = userData.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<File> roms = RomTools.Merge(userData.Files[key], logger);
|
List<Rom> roms = RomTools.Merge(userData.Files[key], logger);
|
||||||
|
|
||||||
if (roms != null && roms.Count > 0)
|
if (roms != null && roms.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (File rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
// No duplicates
|
// No duplicates
|
||||||
if ((diff & DiffMode.NoDupes) != 0 || (diff & DiffMode.Individuals) != 0)
|
if ((diff & DiffMode.NoDupes) != 0 || (diff & DiffMode.Individuals) != 0)
|
||||||
@@ -2061,7 +2061,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> tl = new List<File>();
|
List<Rom> tl = new List<Rom>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
outDats[rom.Metadata.SystemID].Files.Add(key, tl);
|
outDats[rom.Metadata.SystemID].Files.Add(key, tl);
|
||||||
}
|
}
|
||||||
@@ -2070,7 +2070,7 @@ namespace SabreTools.Helper
|
|||||||
// Merged no-duplicates DAT
|
// Merged no-duplicates DAT
|
||||||
if ((diff & DiffMode.NoDupes) != 0)
|
if ((diff & DiffMode.NoDupes) != 0)
|
||||||
{
|
{
|
||||||
File newrom = rom;
|
Rom newrom = rom;
|
||||||
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (outerDiffData.Files.ContainsKey(key))
|
if (outerDiffData.Files.ContainsKey(key))
|
||||||
@@ -2079,7 +2079,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> tl = new List<File>();
|
List<Rom> tl = new List<Rom>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
outerDiffData.Files.Add(key, tl);
|
outerDiffData.Files.Add(key, tl);
|
||||||
}
|
}
|
||||||
@@ -2092,7 +2092,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (rom.Dupe >= DupeType.ExternalHash)
|
if (rom.Dupe >= DupeType.ExternalHash)
|
||||||
{
|
{
|
||||||
File newrom = rom;
|
Rom newrom = rom;
|
||||||
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (dupeData.Files.ContainsKey(key))
|
if (dupeData.Files.ContainsKey(key))
|
||||||
@@ -2101,7 +2101,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> tl = new List<File>();
|
List<Rom> tl = new List<Rom>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
dupeData.Files.Add(key, tl);
|
dupeData.Files.Add(key, tl);
|
||||||
}
|
}
|
||||||
@@ -2194,11 +2194,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<File> roms = RomTools.Merge(userData.Files[key], logger);
|
List<Rom> roms = RomTools.Merge(userData.Files[key], logger);
|
||||||
|
|
||||||
if (roms != null && roms.Count > 0)
|
if (roms != null && roms.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (File rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
if (outDats[rom.Metadata.SystemID].Files.ContainsKey(key))
|
if (outDats[rom.Metadata.SystemID].Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -2206,7 +2206,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<File> tl = new List<File>();
|
List<Rom> tl = new List<Rom>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
outDats[rom.Metadata.SystemID].Files.Add(key, tl);
|
outDats[rom.Metadata.SystemID].Files.Add(key, tl);
|
||||||
}
|
}
|
||||||
@@ -2256,10 +2256,10 @@ namespace SabreTools.Helper
|
|||||||
List<string> keys = userData.Files.Keys.ToList();
|
List<string> keys = userData.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<File> newroms = new List<File>();
|
List<Rom> newroms = new List<Rom>();
|
||||||
foreach (File rom in userData.Files[key])
|
foreach (Rom rom in userData.Files[key])
|
||||||
{
|
{
|
||||||
File newrom = rom;
|
Rom newrom = rom;
|
||||||
string filename = inputs[newrom.Metadata.SystemID].Split('¬')[0];
|
string filename = inputs[newrom.Metadata.SystemID].Split('¬')[0];
|
||||||
string rootpath = inputs[newrom.Metadata.SystemID].Split('¬')[1];
|
string rootpath = inputs[newrom.Metadata.SystemID].Split('¬')[1];
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucket roms by game name and optionally dedupe
|
// Bucket roms by game name and optionally dedupe
|
||||||
SortedDictionary<string, List<File>> sortable = DatTools.BucketByGame(datdata.Files, datdata.MergeRoms, norename, logger);
|
SortedDictionary<string, List<Rom>> sortable = DatTools.BucketByGame(datdata.Files, datdata.MergeRoms, norename, logger);
|
||||||
|
|
||||||
// Now write out to file
|
// Now write out to file
|
||||||
// If it's empty, use the current folder
|
// If it's empty, use the current folder
|
||||||
@@ -95,11 +95,11 @@ namespace SabreTools.Helper
|
|||||||
int depth = 2, last = -1;
|
int depth = 2, last = -1;
|
||||||
string lastgame = null;
|
string lastgame = null;
|
||||||
List<string> splitpath = new List<string>();
|
List<string> splitpath = new List<string>();
|
||||||
foreach (List<File> roms in sortable.Values)
|
foreach (List<Rom> roms in sortable.Values)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < roms.Count; index++)
|
for (int index = 0; index < roms.Count; index++)
|
||||||
{
|
{
|
||||||
File rom = roms[index];
|
Rom rom = roms[index];
|
||||||
List<string> newsplit = rom.Machine.Name.Split('\\').ToList();
|
List<string> newsplit = rom.Machine.Name.Split('\\').ToList();
|
||||||
|
|
||||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||||
@@ -285,7 +285,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <returns>The new depth of the tag</returns>
|
/// <returns>The new depth of the tag</returns>
|
||||||
public static int WriteStartGame(StreamWriter sw, File rom, List<string> newsplit, string lastgame, Dat datdata, int depth, int last, Logger logger)
|
public static int WriteStartGame(StreamWriter sw, Rom rom, List<string> newsplit, string lastgame, Dat datdata, int depth, int last, Logger logger)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -344,7 +344,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <returns>The new depth of the tag</returns>
|
/// <returns>The new depth of the tag</returns>
|
||||||
public static int WriteEndGame(StreamWriter sw, File rom, List<string> splitpath, List<string> newsplit, string lastgame, Dat datdata, int depth, out int last, Logger logger)
|
public static int WriteEndGame(StreamWriter sw, Rom rom, List<string> splitpath, List<string> newsplit, string lastgame, Dat datdata, int depth, out int last, Logger logger)
|
||||||
{
|
{
|
||||||
last = 0;
|
last = 0;
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
/// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
/// <returns>True if the data was written, false on error</returns>
|
/// <returns>True if the data was written, false on error</returns>
|
||||||
public static bool WriteRomData(StreamWriter sw, File rom, string lastgame, Dat datdata, int depth, Logger logger)
|
public static bool WriteRomData(StreamWriter sw, Rom rom, string lastgame, Dat datdata, int depth, Logger logger)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="noSHA1">True if SHA-1 hashes should not be calcluated, false otherwise</param>
|
/// <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>
|
/// <returns>Populated RomData object if success, empty one on error</returns>
|
||||||
/// <remarks>Add read-offset for hash info</remarks>
|
/// <remarks>Add read-offset for hash info</remarks>
|
||||||
public static File GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0)
|
public static Rom GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0)
|
||||||
{
|
{
|
||||||
// Add safeguard if file doesn't exist
|
// Add safeguard if file doesn't exist
|
||||||
if (!System.IO.File.Exists(input))
|
if (!System.IO.File.Exists(input))
|
||||||
{
|
{
|
||||||
return new File();
|
return new Rom();
|
||||||
}
|
}
|
||||||
|
|
||||||
File rom = new File
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Name = Path.GetFileName(input),
|
Name = Path.GetFileName(input),
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
@@ -84,7 +84,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
return new File();
|
return new Rom();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rom;
|
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="inroms">List of RomData objects representing the roms to be merged</param>
|
||||||
/// <param name="logger">Logger object for console and/or file output</param>
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <returns>A List of RomData objects representing the merged roms</returns>
|
/// <returns>A List of RomData objects representing the merged roms</returns>
|
||||||
public static List<File> Merge(List<File> inroms, Logger logger)
|
public static List<Rom> Merge(List<Rom> inroms, Logger logger)
|
||||||
{
|
{
|
||||||
// Check for null or blank roms first
|
// Check for null or blank roms first
|
||||||
if (inroms == null || inroms.Count == 0)
|
if (inroms == null || inroms.Count == 0)
|
||||||
{
|
{
|
||||||
return new List<File>();
|
return new List<Rom>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create output list
|
// Create output list
|
||||||
List<File> outroms = new List<File>();
|
List<Rom> outroms = new List<Rom>();
|
||||||
|
|
||||||
// Then deduplicate them by checking to see if data matches previous saved roms
|
// Then deduplicate them by checking to see if data matches previous saved roms
|
||||||
foreach (File rom in inroms)
|
foreach (Rom rom in inroms)
|
||||||
{
|
{
|
||||||
// If it's a nodump, add and skip
|
// If it's a nodump, add and skip
|
||||||
if (rom.Nodump)
|
if (rom.Nodump)
|
||||||
@@ -122,11 +122,11 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
// Check if the rom is a duplicate
|
// Check if the rom is a duplicate
|
||||||
DupeType dupetype = DupeType.None;
|
DupeType dupetype = DupeType.None;
|
||||||
File savedrom = new File();
|
Rom savedrom = new Rom();
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
for (int i = 0; i < outroms.Count; i++)
|
for (int i = 0; i < outroms.Count; i++)
|
||||||
{
|
{
|
||||||
File lastrom = outroms[i];
|
Rom lastrom = outroms[i];
|
||||||
|
|
||||||
// Get the duplicate status
|
// Get the duplicate status
|
||||||
dupetype = GetDuplicateStatus(rom, lastrom, logger);
|
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="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>
|
/// <param name="remove">True to remove matched roms from the input, false otherwise (default)</param>
|
||||||
/// <returns>List of matched RomData objects</returns>
|
/// <returns>List of matched RomData objects</returns>
|
||||||
public static List<File> GetDuplicates(File lastrom, Dat datdata, Logger logger, bool remove = false)
|
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata, Logger logger, bool remove = false)
|
||||||
{
|
{
|
||||||
List<File> output = new List<File>();
|
List<Rom> output = new List<Rom>();
|
||||||
|
|
||||||
// Check for an empty rom list first
|
// Check for an empty rom list first
|
||||||
if (datdata.Files == null || datdata.Files.Count == 0)
|
if (datdata.Files == null || datdata.Files.Count == 0)
|
||||||
@@ -208,9 +208,9 @@ namespace SabreTools.Helper
|
|||||||
List<string> keys = datdata.Files.Keys.ToList();
|
List<string> keys = datdata.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<File> roms = datdata.Files[key];
|
List<Rom> roms = datdata.Files[key];
|
||||||
List<File> left = new List<File>();
|
List<Rom> left = new List<Rom>();
|
||||||
foreach (File rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
if (IsDuplicate(rom, lastrom, logger))
|
if (IsDuplicate(rom, lastrom, logger))
|
||||||
{
|
{
|
||||||
@@ -239,7 +239,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="lastrom">Rom to use as a baseline</param>
|
/// <param name="lastrom">Rom to use as a baseline</param>
|
||||||
/// <param name="logger">Logger object for console and/or file output</param>
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
||||||
public static bool IsDuplicate(File rom, File lastrom, Logger logger)
|
public static bool IsDuplicate(Rom rom, Rom lastrom, Logger logger)
|
||||||
{
|
{
|
||||||
bool dupefound = false;
|
bool dupefound = false;
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="lastrom">Last rom to check against</param>
|
/// <param name="lastrom">Last rom to check against</param>
|
||||||
/// <param name="logger">Logger object for console and/or file output</param>
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
||||||
public static DupeType GetDuplicateStatus(File rom, File lastrom, Logger logger)
|
public static DupeType GetDuplicateStatus(Rom rom, Rom lastrom, Logger logger)
|
||||||
{
|
{
|
||||||
DupeType output = DupeType.None;
|
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="roms">List of RomData objects representing the roms to be sorted</param>
|
||||||
/// <param name="norename">True if files are not renamed, false otherwise</param>
|
/// <param name="norename">True if files are not renamed, false otherwise</param>
|
||||||
/// <returns>True if it sorted correctly, false otherwise</returns>
|
/// <returns>True if it sorted correctly, false otherwise</returns>
|
||||||
public static bool Sort(List<File> roms, bool norename)
|
public static bool Sort(List<Rom> roms, bool norename)
|
||||||
{
|
{
|
||||||
roms.Sort(delegate (File x, File y)
|
roms.Sort(delegate (Rom x, Rom y)
|
||||||
{
|
{
|
||||||
if (x.Metadata.SystemID == y.Metadata.SystemID)
|
if (x.Metadata.SystemID == y.Metadata.SystemID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace SabreTools.Helper
|
|||||||
List<String> games = new List<String>();
|
List<String> games = new List<String>();
|
||||||
Dat datdata = new Dat();
|
Dat datdata = new Dat();
|
||||||
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
||||||
SortedDictionary<string, List<File>> newroms = DatTools.BucketByGame(datdata.Files, false, true, _logger, false);
|
SortedDictionary<string, List<Rom>> newroms = DatTools.BucketByGame(datdata.Files, false, true, _logger, false);
|
||||||
|
|
||||||
// Output single DAT stats (if asked)
|
// Output single DAT stats (if asked)
|
||||||
if (_single)
|
if (_single)
|
||||||
@@ -116,9 +116,9 @@ Please check the log folder if the stats scrolled offscreen");
|
|||||||
datdata.NodumpCount = 0;
|
datdata.NodumpCount = 0;
|
||||||
|
|
||||||
// Loop through and add
|
// Loop through and add
|
||||||
foreach (List<File> roms in datdata.Files.Values)
|
foreach (List<Rom> roms in datdata.Files.Values)
|
||||||
{
|
{
|
||||||
foreach (File rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
datdata.RomCount += (rom.Type == ItemType.Rom ? 1 : 0);
|
datdata.RomCount += (rom.Type == ItemType.Rom ? 1 : 0);
|
||||||
datdata.DiskCount += (rom.Type == ItemType.Disk ? 1 : 0);
|
datdata.DiskCount += (rom.Type == ItemType.Disk ? 1 : 0);
|
||||||
@@ -131,7 +131,7 @@ Please check the log folder if the stats scrolled offscreen");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SortedDictionary<string, List<File>> newroms = DatTools.BucketByGame(datdata.Files, false, true, logger, false);
|
SortedDictionary<string, List<Rom>> newroms = DatTools.BucketByGame(datdata.Files, false, true, logger, false);
|
||||||
if (datdata.TotalSize < 0)
|
if (datdata.TotalSize < 0)
|
||||||
{
|
{
|
||||||
datdata.TotalSize = Int64.MaxValue + datdata.TotalSize;
|
datdata.TotalSize = Int64.MaxValue + datdata.TotalSize;
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ namespace SabreTools
|
|||||||
if (!items)
|
if (!items)
|
||||||
{
|
{
|
||||||
string actualroot = item.Remove(0, basePathBackup.Length);
|
string actualroot = item.Remove(0, basePathBackup.Length);
|
||||||
Helper.File rom = new Helper.File
|
Helper.Rom rom = new Helper.Rom
|
||||||
{
|
{
|
||||||
Name = "null",
|
Name = "null",
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
@@ -197,7 +197,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
_datdata.Files.Add(key, temp);
|
_datdata.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ namespace SabreTools
|
|||||||
if (Directory.EnumerateFiles(subdir, "*", SearchOption.AllDirectories).Count() == 0)
|
if (Directory.EnumerateFiles(subdir, "*", SearchOption.AllDirectories).Count() == 0)
|
||||||
{
|
{
|
||||||
string actualroot = subdir.Remove(0, basePathBackup.Length);
|
string actualroot = subdir.Remove(0, basePathBackup.Length);
|
||||||
Helper.File rom = new Helper.File
|
Helper.Rom rom = new Helper.Rom
|
||||||
{
|
{
|
||||||
Name = "null",
|
Name = "null",
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
@@ -236,7 +236,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
_datdata.Files.Add(key, temp);
|
_datdata.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -259,10 +259,10 @@ namespace SabreTools
|
|||||||
List<string> keys = _datdata.Files.Keys.ToList();
|
List<string> keys = _datdata.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> roms = _datdata.Files[key];
|
List<Helper.Rom> roms = _datdata.Files[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
|
|
||||||
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
|
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
|
||||||
if (_datdata.OutputFormat != OutputFormat.SabreDat && _datdata.OutputFormat != OutputFormat.MissFile)
|
if (_datdata.OutputFormat != OutputFormat.SabreDat && _datdata.OutputFormat != OutputFormat.MissFile)
|
||||||
@@ -284,7 +284,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
_datdata.Files.Add(inkey, temp);
|
_datdata.Files.Add(inkey, temp);
|
||||||
}
|
}
|
||||||
@@ -318,7 +318,7 @@ namespace SabreTools
|
|||||||
// If we had roms but not blanks (and not in Romba mode), create an artifical rom for the purposes of outputting
|
// If we had roms but not blanks (and not in Romba mode), create an artifical rom for the purposes of outputting
|
||||||
if (lastparent != null && _datdata.Files.Count == 0)
|
if (lastparent != null && _datdata.Files.Count == 0)
|
||||||
{
|
{
|
||||||
_datdata.Files.Add("temp", new List<Helper.File>());
|
_datdata.Files.Add("temp", new List<Helper.Rom>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ namespace SabreTools
|
|||||||
// Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes)
|
// Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes)
|
||||||
if (_datdata.Romba)
|
if (_datdata.Romba)
|
||||||
{
|
{
|
||||||
Helper.File rom = ArchiveTools.GetTorrentGZFileInfo(item, _logger);
|
Helper.Rom rom = ArchiveTools.GetTorrentGZFileInfo(item, _logger);
|
||||||
|
|
||||||
// If the rom is valid, write it out
|
// If the rom is valid, write it out
|
||||||
if (rom.Name != null)
|
if (rom.Name != null)
|
||||||
@@ -362,7 +362,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
_datdata.Files.Add(key, temp);
|
_datdata.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -391,8 +391,8 @@ namespace SabreTools
|
|||||||
// If we have an archive, scan it
|
// If we have an archive, scan it
|
||||||
if (type != null)
|
if (type != null)
|
||||||
{
|
{
|
||||||
List<Helper.File> extracted = ArchiveTools.GetArchiveFileInfo(item, _logger);
|
List<Helper.Rom> extracted = ArchiveTools.GetArchiveFileInfo(item, _logger);
|
||||||
foreach (Helper.File rom in extracted)
|
foreach (Helper.Rom rom in extracted)
|
||||||
{
|
{
|
||||||
lastparent = ProcessFileHelper(item, rom, sw, _basePath,
|
lastparent = ProcessFileHelper(item, rom, sw, _basePath,
|
||||||
Path.Combine((Path.GetDirectoryName(Path.GetFullPath(item)) + Path.DirectorySeparatorChar).Remove(0, _basePath.Length) +
|
Path.Combine((Path.GetDirectoryName(Path.GetFullPath(item)) + Path.DirectorySeparatorChar).Remove(0, _basePath.Length) +
|
||||||
@@ -462,7 +462,7 @@ namespace SabreTools
|
|||||||
private string ProcessFile(string item, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent)
|
private string ProcessFile(string item, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent)
|
||||||
{
|
{
|
||||||
_logger.Log(Path.GetFileName(item) + " treated like a file");
|
_logger.Log(Path.GetFileName(item) + " treated like a file");
|
||||||
Helper.File rom = RomTools.GetSingleFileInfo(item, _noMD5, _noSHA1);
|
Helper.Rom rom = RomTools.GetSingleFileInfo(item, _noMD5, _noSHA1);
|
||||||
|
|
||||||
return ProcessFileHelper(item, rom, sw, basepath, parent, datdata, lastparent);
|
return ProcessFileHelper(item, rom, sw, basepath, parent, datdata, lastparent);
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ namespace SabreTools
|
|||||||
/// <param name="datdata">DatData object with output information</param>
|
/// <param name="datdata">DatData object with output information</param>
|
||||||
/// <param name="lastparent">Last known parent game name</param>
|
/// <param name="lastparent">Last known parent game name</param>
|
||||||
/// <returns>New last known parent game name</returns>
|
/// <returns>New last known parent game name</returns>
|
||||||
private string ProcessFileHelper(string item, Helper.File rom, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent)
|
private string ProcessFileHelper(string item, Helper.Rom rom, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -537,7 +537,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
_datdata.Files.Add(key, temp);
|
_datdata.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,11 +188,11 @@ namespace SabreTools
|
|||||||
List<string> keys = datdata.Files.Keys.ToList();
|
List<string> keys = datdata.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> newroms = datdata.Files[key];
|
List<Helper.Rom> newroms = datdata.Files[key];
|
||||||
for (int i = 0; i < newroms.Count; i++)
|
for (int i = 0; i < newroms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = newroms[i];
|
Helper.Rom rom = newroms[i];
|
||||||
|
|
||||||
// In the case that the RomData is incomplete, skip it
|
// In the case that the RomData is incomplete, skip it
|
||||||
if (rom.Name == null || rom.Machine.Name == null)
|
if (rom.Name == null || rom.Machine.Name == null)
|
||||||
|
|||||||
@@ -63,11 +63,11 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Now get Net New output dictionary [(currentNewMerged)-(currentAllMerged)]
|
// Now get Net New output dictionary [(currentNewMerged)-(currentAllMerged)]
|
||||||
_logger.User("Creating and populating Net New dictionary");
|
_logger.User("Creating and populating Net New dictionary");
|
||||||
Dictionary<string, List<Helper.File>> netNew = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> netNew = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in completeDats.Files.Keys)
|
foreach (string key in completeDats.Files.Keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = RomTools.Merge(completeDats.Files[key], _logger);
|
List<Helper.Rom> templist = RomTools.Merge(completeDats.Files[key], _logger);
|
||||||
foreach (Helper.File rom in templist)
|
foreach (Helper.Rom rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
netNew.Add(key, temp);
|
netNew.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -87,11 +87,11 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Now create the Unneeded dictionary [(currentAllMerged)-(currentNewMerged)]
|
// Now create the Unneeded dictionary [(currentAllMerged)-(currentNewMerged)]
|
||||||
_logger.User("Creating and populating Uneeded dictionary");
|
_logger.User("Creating and populating Uneeded dictionary");
|
||||||
Dictionary<string, List<Helper.File>> unneeded = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> unneeded = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in completeDats.Files.Keys)
|
foreach (string key in completeDats.Files.Keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = RomTools.Merge(completeDats.Files[key], _logger);
|
List<Helper.Rom> templist = RomTools.Merge(completeDats.Files[key], _logger);
|
||||||
foreach (Helper.File rom in templist)
|
foreach (Helper.Rom rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged)
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
unneeded.Add(key, temp);
|
unneeded.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -124,11 +124,11 @@ namespace SabreTools
|
|||||||
midMissing.Files.Add(key, unneeded[key]);
|
midMissing.Files.Add(key, unneeded[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Dictionary<string, List<Helper.File>> newMissing = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> newMissing = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in midMissing.Files.Keys)
|
foreach (string key in midMissing.Files.Keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = RomTools.Merge(midMissing.Files[key], _logger);
|
List<Helper.Rom> templist = RomTools.Merge(midMissing.Files[key], _logger);
|
||||||
foreach (Helper.File rom in templist)
|
foreach (Helper.Rom rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentMissingMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentMissingMerged)
|
||||||
{
|
{
|
||||||
@@ -138,7 +138,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
newMissing.Add(key, temp);
|
newMissing.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Now create the Have dictionary [(currentNewMerged)-(c)]
|
// Now create the Have dictionary [(currentNewMerged)-(c)]
|
||||||
_logger.User("Creating and populating Have dictionary");
|
_logger.User("Creating and populating Have dictionary");
|
||||||
Dictionary<string, List<Helper.File>> midHave = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> midHave = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in newMissing.Keys)
|
foreach (string key in newMissing.Keys)
|
||||||
{
|
{
|
||||||
if (midHave.ContainsKey(key))
|
if (midHave.ContainsKey(key))
|
||||||
@@ -175,7 +175,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
if (midHave.ContainsKey(key))
|
if (midHave.ContainsKey(key))
|
||||||
{
|
{
|
||||||
foreach (Helper.File rom in completeDats.Files[key])
|
foreach (Helper.Rom rom in completeDats.Files[key])
|
||||||
{
|
{
|
||||||
if (rom.Metadata.System == _currentNewMerged)
|
if (rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
@@ -185,8 +185,8 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> roms = new List<Helper.File>();
|
List<Helper.Rom> roms = new List<Helper.Rom>();
|
||||||
foreach (Helper.File rom in completeDats.Files[key])
|
foreach (Helper.Rom rom in completeDats.Files[key])
|
||||||
{
|
{
|
||||||
if (rom.Metadata.System == _currentNewMerged)
|
if (rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
@@ -196,11 +196,11 @@ namespace SabreTools
|
|||||||
midHave.Add(key, roms);
|
midHave.Add(key, roms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Dictionary<string, List<Helper.File>> have = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> have = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in midHave.Keys)
|
foreach (string key in midHave.Keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = RomTools.Merge(midHave[key], _logger);
|
List<Helper.Rom> templist = RomTools.Merge(midHave[key], _logger);
|
||||||
foreach (Helper.File rom in templist)
|
foreach (Helper.Rom rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
@@ -210,7 +210,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
have.Add(key, temp);
|
have.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -225,11 +225,11 @@ namespace SabreTools
|
|||||||
List<string> keys = netNew.Keys.ToList();
|
List<string> keys = netNew.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> roms = netNew[key];
|
List<Helper.Rom> roms = netNew[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
rom.HashData.Size = Constants.SizeZero;
|
rom.HashData.Size = Constants.SizeZero;
|
||||||
rom.HashData.CRC = Constants.CRCZero;
|
rom.HashData.CRC = Constants.CRCZero;
|
||||||
rom.HashData.MD5 = Constants.MD5Zero;
|
rom.HashData.MD5 = Constants.MD5Zero;
|
||||||
@@ -243,11 +243,11 @@ namespace SabreTools
|
|||||||
keys = unneeded.Keys.ToList();
|
keys = unneeded.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> roms = unneeded[key];
|
List<Helper.Rom> roms = unneeded[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
rom.HashData.Size = Constants.SizeZero;
|
rom.HashData.Size = Constants.SizeZero;
|
||||||
rom.HashData.CRC = Constants.CRCZero;
|
rom.HashData.CRC = Constants.CRCZero;
|
||||||
rom.HashData.MD5 = Constants.MD5Zero;
|
rom.HashData.MD5 = Constants.MD5Zero;
|
||||||
@@ -261,11 +261,11 @@ namespace SabreTools
|
|||||||
keys = newMissing.Keys.ToList();
|
keys = newMissing.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> roms = newMissing[key];
|
List<Helper.Rom> roms = newMissing[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
rom.HashData.Size = Constants.SizeZero;
|
rom.HashData.Size = Constants.SizeZero;
|
||||||
rom.HashData.CRC = Constants.CRCZero;
|
rom.HashData.CRC = Constants.CRCZero;
|
||||||
rom.HashData.MD5 = Constants.MD5Zero;
|
rom.HashData.MD5 = Constants.MD5Zero;
|
||||||
@@ -279,11 +279,11 @@ namespace SabreTools
|
|||||||
keys = have.Keys.ToList();
|
keys = have.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> roms = have[key];
|
List<Helper.Rom> roms = have[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
rom.HashData.Size = Constants.SizeZero;
|
rom.HashData.Size = Constants.SizeZero;
|
||||||
rom.HashData.CRC = Constants.CRCZero;
|
rom.HashData.CRC = Constants.CRCZero;
|
||||||
rom.HashData.MD5 = Constants.MD5Zero;
|
rom.HashData.MD5 = Constants.MD5Zero;
|
||||||
@@ -364,11 +364,11 @@ namespace SabreTools
|
|||||||
Dat midHave = new Dat();
|
Dat midHave = new Dat();
|
||||||
midHave = DatTools.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
midHave = DatTools.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
||||||
midHave = DatTools.Parse(_currentAllMerged, 0, 0, midHave, _logger);
|
midHave = DatTools.Parse(_currentAllMerged, 0, 0, midHave, _logger);
|
||||||
Dictionary<string, List<Helper.File>> have = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> have = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in midHave.Files.Keys)
|
foreach (string key in midHave.Files.Keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = RomTools.Merge(midHave.Files[key], _logger);
|
List<Helper.Rom> templist = RomTools.Merge(midHave.Files[key], _logger);
|
||||||
foreach (Helper.File rom in templist)
|
foreach (Helper.Rom rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged)
|
||||||
{
|
{
|
||||||
@@ -378,7 +378,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
have.Add(key, temp);
|
have.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -393,11 +393,11 @@ namespace SabreTools
|
|||||||
List<string> keys = have.Keys.ToList();
|
List<string> keys = have.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> roms = have[key];
|
List<Helper.Rom> roms = have[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
rom.HashData.Size = Constants.SizeZero;
|
rom.HashData.Size = Constants.SizeZero;
|
||||||
rom.HashData.CRC = Constants.CRCZero;
|
rom.HashData.CRC = Constants.CRCZero;
|
||||||
rom.HashData.MD5 = Constants.MD5Zero;
|
rom.HashData.MD5 = Constants.MD5Zero;
|
||||||
@@ -434,11 +434,11 @@ namespace SabreTools
|
|||||||
Dat midHave = new Dat();
|
Dat midHave = new Dat();
|
||||||
midHave = DatTools.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
midHave = DatTools.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
||||||
midHave = DatTools.Parse(_currentNewMerged, 0, 0, midHave, _logger);
|
midHave = DatTools.Parse(_currentNewMerged, 0, 0, midHave, _logger);
|
||||||
Dictionary<string, List<Helper.File>> have = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> have = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in midHave.Files.Keys)
|
foreach (string key in midHave.Files.Keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = RomTools.Merge(midHave.Files[key], _logger);
|
List<Helper.Rom> templist = RomTools.Merge(midHave.Files[key], _logger);
|
||||||
foreach (Helper.File rom in templist)
|
foreach (Helper.Rom rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
@@ -448,7 +448,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
have.Add(key, temp);
|
have.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -463,11 +463,11 @@ namespace SabreTools
|
|||||||
List<string> keys = have.Keys.ToList();
|
List<string> keys = have.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
List<Helper.File> roms = have[key];
|
List<Helper.Rom> roms = have[key];
|
||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
Helper.File rom = roms[i];
|
Helper.Rom rom = roms[i];
|
||||||
rom.HashData.Size = Constants.SizeZero;
|
rom.HashData.Size = Constants.SizeZero;
|
||||||
rom.HashData.CRC = Constants.CRCZero;
|
rom.HashData.CRC = Constants.CRCZero;
|
||||||
rom.HashData.MD5 = Constants.MD5Zero;
|
rom.HashData.MD5 = Constants.MD5Zero;
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ namespace SabreTools
|
|||||||
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
Romba = romba,
|
Romba = romba,
|
||||||
Type = (superdat ? "SuperDAT" : ""),
|
Type = (superdat ? "SuperDAT" : ""),
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
};
|
};
|
||||||
DATFromDir dfd = new DATFromDir(inputs, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, _logger);
|
DATFromDir dfd = new DATFromDir(inputs, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, _logger);
|
||||||
bool success = dfd.Start();
|
bool success = dfd.Start();
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace SabreTools
|
|||||||
ForcePacking = datdata.ForcePacking,
|
ForcePacking = datdata.ForcePacking,
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
MergeRoms = datdata.MergeRoms,
|
MergeRoms = datdata.MergeRoms,
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
};
|
};
|
||||||
Dat sha1 = new Dat
|
Dat sha1 = new Dat
|
||||||
{
|
{
|
||||||
@@ -177,7 +177,7 @@ namespace SabreTools
|
|||||||
ForcePacking = datdata.ForcePacking,
|
ForcePacking = datdata.ForcePacking,
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
MergeRoms = datdata.MergeRoms,
|
MergeRoms = datdata.MergeRoms,
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
};
|
};
|
||||||
Dat md5 = new Dat
|
Dat md5 = new Dat
|
||||||
{
|
{
|
||||||
@@ -199,7 +199,7 @@ namespace SabreTools
|
|||||||
ForcePacking = datdata.ForcePacking,
|
ForcePacking = datdata.ForcePacking,
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
MergeRoms = datdata.MergeRoms,
|
MergeRoms = datdata.MergeRoms,
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
};
|
};
|
||||||
Dat crc = new Dat
|
Dat crc = new Dat
|
||||||
{
|
{
|
||||||
@@ -221,15 +221,15 @@ namespace SabreTools
|
|||||||
ForcePacking = datdata.ForcePacking,
|
ForcePacking = datdata.ForcePacking,
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
MergeRoms = datdata.MergeRoms,
|
MergeRoms = datdata.MergeRoms,
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now populate each of the DAT objects in turn
|
// Now populate each of the DAT objects in turn
|
||||||
List<string> keys = datdata.Files.Keys.ToList();
|
List<string> keys = datdata.Files.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
List<Helper.File> roms = datdata.Files[key];
|
List<Helper.Rom> roms = datdata.Files[key];
|
||||||
foreach (Helper.File rom in roms)
|
foreach (Helper.Rom rom in roms)
|
||||||
{
|
{
|
||||||
// If the file is a nodump
|
// If the file is a nodump
|
||||||
if (rom.Nodump)
|
if (rom.Nodump)
|
||||||
@@ -240,7 +240,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
nodump.Files.Add(key, temp);
|
nodump.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
sha1.Files.Add(key, temp);
|
sha1.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
md5.Files.Add(key, temp);
|
md5.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
crc.Files.Add(key, temp);
|
crc.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ namespace SabreTools
|
|||||||
Homepage = datdata.Homepage,
|
Homepage = datdata.Homepage,
|
||||||
Url = datdata.Url,
|
Url = datdata.Url,
|
||||||
Comment = datdata.Comment,
|
Comment = datdata.Comment,
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
};
|
};
|
||||||
Dat datdataB = new Dat
|
Dat datdataB = new Dat
|
||||||
@@ -367,7 +367,7 @@ namespace SabreTools
|
|||||||
Homepage = datdata.Homepage,
|
Homepage = datdata.Homepage,
|
||||||
Url = datdata.Url,
|
Url = datdata.Url,
|
||||||
Comment = datdata.Comment,
|
Comment = datdata.Comment,
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ namespace SabreTools
|
|||||||
// Now separate the roms accordingly
|
// Now separate the roms accordingly
|
||||||
foreach (string key in datdata.Files.Keys)
|
foreach (string key in datdata.Files.Keys)
|
||||||
{
|
{
|
||||||
foreach (Helper.File rom in datdata.Files[key])
|
foreach (Helper.Rom rom in datdata.Files[key])
|
||||||
{
|
{
|
||||||
if (_extA.Contains(Path.GetExtension(rom.Name.ToUpperInvariant())))
|
if (_extA.Contains(Path.GetExtension(rom.Name.ToUpperInvariant())))
|
||||||
{
|
{
|
||||||
@@ -390,7 +390,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
datdataA.Files.Add(key, temp);
|
datdataA.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
datdataB.Files.Add(key, temp);
|
datdataB.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
datdataA.Files.Add(key, temp);
|
datdataA.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
datdataB.Files.Add(key, temp);
|
datdataB.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace SabreTools
|
|||||||
_cursorLeft = Console.CursorLeft;
|
_cursorLeft = Console.CursorLeft;
|
||||||
_matched = new Dat
|
_matched = new Dat
|
||||||
{
|
{
|
||||||
Files = new Dictionary<string, List<Helper.File>>(),
|
Files = new Dictionary<string, List<Helper.Rom>>(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Setup the fixdat
|
// Setup the fixdat
|
||||||
_matched = (Dat)_datdata.CloneHeader();
|
_matched = (Dat)_datdata.CloneHeader();
|
||||||
_matched.Files = new Dictionary<string, List<Helper.File>>();
|
_matched.Files = new Dictionary<string, List<Helper.Rom>>();
|
||||||
_matched.FileName = "fixDat_" + _matched.FileName;
|
_matched.FileName = "fixDat_" + _matched.FileName;
|
||||||
_matched.Name = "fixDat_" + _matched.Name;
|
_matched.Name = "fixDat_" + _matched.Name;
|
||||||
_matched.Description = "fixDat_" + _matched.Description;
|
_matched.Description = "fixDat_" + _matched.Description;
|
||||||
@@ -366,10 +366,10 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Now that all files are parsed, get only files found in directory
|
// Now that all files are parsed, get only files found in directory
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach (List<Helper.File> roms in _datdata.Files.Values)
|
foreach (List<Helper.Rom> roms in _datdata.Files.Values)
|
||||||
{
|
{
|
||||||
List<Helper.File> newroms = RomTools.Merge(roms, _logger);
|
List<Helper.Rom> newroms = RomTools.Merge(roms, _logger);
|
||||||
foreach (Helper.File rom in newroms)
|
foreach (Helper.Rom rom in newroms)
|
||||||
{
|
{
|
||||||
if (rom.Metadata.SourceID == 99)
|
if (rom.Metadata.SourceID == 99)
|
||||||
{
|
{
|
||||||
@@ -381,7 +381,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
_matched.Files.Add(key, temp);
|
_matched.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ namespace SabreTools
|
|||||||
// Hash and match the external files
|
// Hash and match the external files
|
||||||
if (shouldExternalScan)
|
if (shouldExternalScan)
|
||||||
{
|
{
|
||||||
Helper.File rom = RomTools.GetSingleFileInfo(input);
|
Helper.Rom rom = RomTools.GetSingleFileInfo(input);
|
||||||
|
|
||||||
// If we have a blank RomData, it's an error
|
// If we have a blank RomData, it's an error
|
||||||
if (rom.Name == null)
|
if (rom.Name == null)
|
||||||
@@ -501,9 +501,9 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<Helper.File> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true);
|
List<Helper.Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true);
|
||||||
_logger.Log("File '" + input + "' had " + foundroms.Count + " matches in the DAT!");
|
_logger.Log("File '" + input + "' had " + foundroms.Count + " matches in the DAT!");
|
||||||
foreach (Helper.File found in foundroms)
|
foreach (Helper.Rom found in foundroms)
|
||||||
{
|
{
|
||||||
_logger.Log("Matched name: " + found.Name);
|
_logger.Log("Matched name: " + found.Name);
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(found);
|
temp.Add(found);
|
||||||
_matched.Files.Add(key, temp);
|
_matched.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -558,7 +558,7 @@ namespace SabreTools
|
|||||||
// Otherwise, apply the rule ot the file
|
// Otherwise, apply the rule ot the file
|
||||||
string newinput = input + ".new";
|
string newinput = input + ".new";
|
||||||
Skippers.TransformFile(input, newinput, rule, _logger);
|
Skippers.TransformFile(input, newinput, rule, _logger);
|
||||||
Helper.File drom = RomTools.GetSingleFileInfo(newinput);
|
Helper.Rom drom = RomTools.GetSingleFileInfo(newinput);
|
||||||
|
|
||||||
// If we have a blank RomData, it's an error
|
// If we have a blank RomData, it's an error
|
||||||
if (drom.Name == null)
|
if (drom.Name == null)
|
||||||
@@ -567,9 +567,9 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<Helper.File> founddroms = RomTools.GetDuplicates(drom, _datdata, _logger, true);
|
List<Helper.Rom> founddroms = RomTools.GetDuplicates(drom, _datdata, _logger, true);
|
||||||
_logger.Log("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!");
|
_logger.Log("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!");
|
||||||
foreach (Helper.File found in founddroms)
|
foreach (Helper.Rom found in founddroms)
|
||||||
{
|
{
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
||||||
@@ -579,7 +579,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(found);
|
temp.Add(found);
|
||||||
_matched.Files.Add(key, temp);
|
_matched.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -616,7 +616,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then output the headered rom (renamed)
|
// Then output the headered rom (renamed)
|
||||||
Helper.File newfound = found;
|
Helper.Rom newfound = found;
|
||||||
newfound.Name = Path.GetFileNameWithoutExtension(newfound.Name) + " (" + rom.HashData.CRC + ")" + Path.GetExtension(newfound.Name);
|
newfound.Name = Path.GetFileNameWithoutExtension(newfound.Name) + " (" + rom.HashData.CRC + ")" + Path.GetExtension(newfound.Name);
|
||||||
|
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
@@ -627,7 +627,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(newfound);
|
temp.Add(newfound);
|
||||||
_matched.Files.Add(key, temp);
|
_matched.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -681,18 +681,18 @@ namespace SabreTools
|
|||||||
if (_quickScan)
|
if (_quickScan)
|
||||||
{
|
{
|
||||||
_logger.Log("Beginning quick scan of contents from '" + input + "'");
|
_logger.Log("Beginning quick scan of contents from '" + input + "'");
|
||||||
List<Helper.File> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
List<Helper.Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
||||||
_logger.Log(internalRomData.Count + " entries found in '" + input + "'");
|
_logger.Log(internalRomData.Count + " entries found in '" + input + "'");
|
||||||
|
|
||||||
// If the list is populated, then the file was a filled archive
|
// If the list is populated, then the file was a filled archive
|
||||||
if (internalRomData.Count > 0)
|
if (internalRomData.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (Helper.File rom in internalRomData)
|
foreach (Helper.Rom rom in internalRomData)
|
||||||
{
|
{
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<Helper.File> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true);
|
List<Helper.Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true);
|
||||||
_logger.Log("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!");
|
_logger.Log("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!");
|
||||||
foreach (Helper.File found in foundroms)
|
foreach (Helper.Rom found in foundroms)
|
||||||
{
|
{
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
||||||
@@ -702,7 +702,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> temp = new List<Helper.File>();
|
List<Helper.Rom> temp = new List<Helper.Rom>();
|
||||||
temp.Add(found);
|
temp.Add(found);
|
||||||
_matched.Files.Add(key, temp);
|
_matched.Files.Add(key, temp);
|
||||||
}
|
}
|
||||||
@@ -825,11 +825,11 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now process the inputs (assumed that it's archived sets as of right now
|
// Now process the inputs (assumed that it's archived sets as of right now
|
||||||
Dictionary<string, List<Helper.File>> scanned = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> scanned = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string archive in Directory.EnumerateFiles(_outdir, "*", SearchOption.AllDirectories))
|
foreach (string archive in Directory.EnumerateFiles(_outdir, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
// If we are in quickscan, get the list of roms that way
|
// If we are in quickscan, get the list of roms that way
|
||||||
List<Helper.File> roms = new List<Helper.File>();
|
List<Helper.Rom> roms = new List<Helper.Rom>();
|
||||||
if (_quickScan)
|
if (_quickScan)
|
||||||
{
|
{
|
||||||
roms = ArchiveTools.GetArchiveFileInfo(Path.GetFullPath(archive), _logger);
|
roms = ArchiveTools.GetArchiveFileInfo(Path.GetFullPath(archive), _logger);
|
||||||
@@ -849,7 +849,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then add each of the found files to the new dictionary
|
// Then add each of the found files to the new dictionary
|
||||||
foreach (Helper.File rom in roms)
|
foreach (Helper.Rom rom in roms)
|
||||||
{
|
{
|
||||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
||||||
if (scanned.ContainsKey(key))
|
if (scanned.ContainsKey(key))
|
||||||
@@ -858,7 +858,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = new List<Helper.File>();
|
List<Helper.Rom> templist = new List<Helper.Rom>();
|
||||||
templist.Add(rom);
|
templist.Add(rom);
|
||||||
scanned.Add(key, templist);
|
scanned.Add(key, templist);
|
||||||
}
|
}
|
||||||
@@ -872,7 +872,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have all of the from DAT and from folder roms, we try to match them, removing the perfect matches
|
// Now that we have all of the from DAT and from folder roms, we try to match them, removing the perfect matches
|
||||||
Dictionary<string, List<Helper.File>> remove = new Dictionary<string, List<Helper.File>>();
|
Dictionary<string, List<Helper.Rom>> remove = new Dictionary<string, List<Helper.Rom>>();
|
||||||
foreach (string key in scanned.Keys)
|
foreach (string key in scanned.Keys)
|
||||||
{
|
{
|
||||||
// If the key doesn't even exist in the DAT, then mark the entire key for removal
|
// If the key doesn't even exist in the DAT, then mark the entire key for removal
|
||||||
@@ -890,9 +890,9 @@ namespace SabreTools
|
|||||||
// Otherwise check each of the values individually
|
// Otherwise check each of the values individually
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> romsList = _datdata.Files[key];
|
List<Helper.Rom> romsList = _datdata.Files[key];
|
||||||
List<Helper.File> scannedList = scanned[key];
|
List<Helper.Rom> scannedList = scanned[key];
|
||||||
foreach (Helper.File rom in scannedList)
|
foreach (Helper.Rom rom in scannedList)
|
||||||
{
|
{
|
||||||
if (!romsList.Contains(rom))
|
if (!romsList.Contains(rom))
|
||||||
{
|
{
|
||||||
@@ -902,7 +902,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Helper.File> templist = new List<Helper.File>();
|
List<Helper.Rom> templist = new List<Helper.Rom>();
|
||||||
templist.Add(rom);
|
templist.Add(rom);
|
||||||
remove.Add(key, templist);
|
remove.Add(key, templist);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user