mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] RomData becomes Rom, DatData becomes Dat
This commit is contained in:
@@ -18,7 +18,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="input">Input filename to be moved</param>
|
||||
/// <param name="output">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
public static void WriteToArchive(string input, string output, RomData rom)
|
||||
public static void WriteToArchive(string input, string output, Rom rom)
|
||||
{
|
||||
string archiveFileName = output + Path.DirectorySeparatorChar + rom.Game + ".zip";
|
||||
|
||||
@@ -311,9 +311,9 @@ namespace SabreTools.Helper
|
||||
/// <param name="input">Input file to get data from</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>List of RomData objects representing the found data</returns>
|
||||
public static List<RomData> GetArchiveFileInfo(string input, Logger logger)
|
||||
public static List<Rom> GetArchiveFileInfo(string input, Logger logger)
|
||||
{
|
||||
List<RomData> roms = new List<RomData>();
|
||||
List<Rom> roms = new List<Rom>();
|
||||
string gamename = Path.GetFileNameWithoutExtension(input);
|
||||
|
||||
// First get the archive type
|
||||
@@ -339,7 +339,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
logger.Log("Entry found: '" + reader.Entry.Key + "': " + reader.Entry.Size + ", " + reader.Entry.Crc.ToString("X").ToLowerInvariant());
|
||||
|
||||
roms.Add(new RomData
|
||||
roms.Add(new Rom
|
||||
{
|
||||
Type = "rom",
|
||||
Name = reader.Entry.Key,
|
||||
@@ -369,7 +369,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="input">Filename to get information from</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>Populated RomData object if success, empty one on error</returns>
|
||||
public static RomData GetTorrentGZFileInfo(string input, Logger logger)
|
||||
public static Rom GetTorrentGZFileInfo(string input, Logger logger)
|
||||
{
|
||||
string datum = Path.GetFileName(input).ToLowerInvariant();
|
||||
long filesize = new FileInfo(input).Length;
|
||||
@@ -378,14 +378,14 @@ namespace SabreTools.Helper
|
||||
if (!Regex.IsMatch(datum, @"^[0-9a-f]{40}\.gz"))
|
||||
{
|
||||
logger.Warning("Non SHA-1 filename found, skipping: '" + datum + "'");
|
||||
return new RomData();
|
||||
return new Rom();
|
||||
}
|
||||
|
||||
// Check if the file is at least the minimum length
|
||||
if (filesize < 32 /* bytes */)
|
||||
{
|
||||
logger.Warning("Possibly corrupt file '" + input + "' with size " + Style.GetBytesReadable(filesize));
|
||||
return new RomData();
|
||||
return new Rom();
|
||||
}
|
||||
|
||||
// Get the Romba-specific header data
|
||||
@@ -430,7 +430,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
}
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Type = "rom",
|
||||
Game = Path.GetFileNameWithoutExtension(input),
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <returns>DatData object representing the read-in data</returns>
|
||||
public static DatData Parse(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep = false, bool clean = false)
|
||||
public static Dat Parse(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep = false, bool clean = false)
|
||||
{
|
||||
// If the output filename isn't set already, get the internal filename
|
||||
if (String.IsNullOrEmpty(datdata.FileName))
|
||||
@@ -94,7 +94,7 @@ namespace SabreTools.Helper
|
||||
// Make sure there's a dictionary to read to
|
||||
if (datdata.Roms == null)
|
||||
{
|
||||
datdata.Roms = new Dictionary<string, List<RomData>>();
|
||||
datdata.Roms = new Dictionary<string, List<Rom>>();
|
||||
}
|
||||
|
||||
// Now parse the correct type of DAT
|
||||
@@ -123,7 +123,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <returns>DatData object representing the read-in data</returns>
|
||||
public static DatData ParseCMP(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep, bool clean)
|
||||
public static Dat ParseCMP(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep, bool clean)
|
||||
{
|
||||
// Read the input file, if possible
|
||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
||||
@@ -169,7 +169,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
gamename = (clean ? Style.CleanGameName(gamename) : gamename);
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = gamename,
|
||||
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
|
||||
@@ -339,7 +339,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> templist = new List<RomData>();
|
||||
List<Rom> templist = new List<Rom>();
|
||||
templist.Add(rom);
|
||||
datdata.Roms.Add(key, templist);
|
||||
}
|
||||
@@ -455,7 +455,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="logger">Logger object for console and/or file output</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <returns>DatData object representing the read-in data</returns>
|
||||
public static DatData ParseRC(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool clean)
|
||||
public static Dat ParseRC(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool clean)
|
||||
{
|
||||
// Read the input file, if possible
|
||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
||||
@@ -570,7 +570,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
rominfo[3] = (clean ? Style.CleanGameName(rominfo[3]) : rominfo[3]);
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = rominfo[3],
|
||||
Name = rominfo[5],
|
||||
@@ -640,7 +640,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> templist = new List<RomData>();
|
||||
List<Rom> templist = new List<Rom>();
|
||||
templist.Add(rom);
|
||||
datdata.Roms.Add(key, templist);
|
||||
}
|
||||
@@ -674,7 +674,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <returns>DatData object representing the read-in data</returns>
|
||||
public static DatData ParseXML(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep, bool clean)
|
||||
public static Dat ParseXML(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep, bool clean)
|
||||
{
|
||||
// Prepare all internal variables
|
||||
XmlReader subreader, headreader, flagreader;
|
||||
@@ -700,7 +700,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
tempgame = (clean ? Style.CleanGameName(tempgame) : tempgame);
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Type = "rom",
|
||||
Name = "null",
|
||||
@@ -718,7 +718,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> temp = new List<RomData>();
|
||||
List<Rom> temp = new List<Rom>();
|
||||
temp.Add(rom);
|
||||
datdata.Roms.Add(key, temp);
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ namespace SabreTools.Helper
|
||||
if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore")
|
||||
{
|
||||
int index = datdata.Roms[key].Count() - 1;
|
||||
RomData lastrom = datdata.Roms[key][index];
|
||||
Rom lastrom = datdata.Roms[key][index];
|
||||
lastrom.Size += size;
|
||||
datdata.Roms[key].RemoveAt(index);
|
||||
datdata.Roms[key].Add(lastrom);
|
||||
@@ -1145,7 +1145,7 @@ namespace SabreTools.Helper
|
||||
// Get the new values to add
|
||||
key = size + "-" + crc;
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = tempname,
|
||||
Name = subreader.GetAttribute("name"),
|
||||
@@ -1165,7 +1165,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> newvalue = new List<RomData>();
|
||||
List<Rom> newvalue = new List<Rom>();
|
||||
newvalue.Add(rom);
|
||||
datdata.Roms.Add(key, newvalue);
|
||||
}
|
||||
@@ -1197,7 +1197,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
tempname = (clean ? Style.CleanGameName(tempname.Split(Path.DirectorySeparatorChar)) : tempname);
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Type = "rom",
|
||||
Name = "null",
|
||||
@@ -1215,7 +1215,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> temp = new List<RomData>();
|
||||
List<Rom> temp = new List<Rom>();
|
||||
temp.Add(rom);
|
||||
datdata.Roms.Add(key, temp);
|
||||
}
|
||||
@@ -1316,7 +1316,7 @@ namespace SabreTools.Helper
|
||||
if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore")
|
||||
{
|
||||
int index = datdata.Roms[key].Count() - 1;
|
||||
RomData lastrom = datdata.Roms[key][index];
|
||||
Rom lastrom = datdata.Roms[key][index];
|
||||
lastrom.Size += size;
|
||||
datdata.Roms[key].RemoveAt(index);
|
||||
datdata.Roms[key].Add(lastrom);
|
||||
@@ -1380,7 +1380,7 @@ namespace SabreTools.Helper
|
||||
// Get the new values to add
|
||||
key = size + "-" + crc;
|
||||
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = tempname,
|
||||
Name = xtr.GetAttribute("name"),
|
||||
@@ -1400,7 +1400,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> newvalue = new List<RomData>();
|
||||
List<Rom> newvalue = new List<Rom>();
|
||||
newvalue.Add(rom);
|
||||
datdata.Roms.Add(key, newvalue);
|
||||
}
|
||||
@@ -1438,9 +1438,9 @@ namespace SabreTools.Helper
|
||||
/// <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>
|
||||
/// <returns>SortedDictionary bucketed by game name</returns>
|
||||
public static SortedDictionary<string, List<RomData>> BucketByGame(List<RomData> 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<RomData>> dict = new Dictionary<string, List<RomData>>();
|
||||
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||
dict.Add("key", list);
|
||||
return BucketByGame(dict, mergeroms, norename, logger, output);
|
||||
}
|
||||
@@ -1454,9 +1454,9 @@ namespace SabreTools.Helper
|
||||
/// <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>
|
||||
/// <returns>SortedDictionary bucketed by game name</returns>
|
||||
public static SortedDictionary<string, List<RomData>> BucketByGame(IDictionary<string, List<RomData>> 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<RomData>> sortable = new SortedDictionary<string, List<RomData>>();
|
||||
SortedDictionary<string, List<Rom>> sortable = new SortedDictionary<string, List<Rom>>();
|
||||
long count = 0;
|
||||
|
||||
// If we have a null dict or an empty one, output a new dictionary
|
||||
@@ -1466,15 +1466,15 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Process each all of the roms
|
||||
foreach (List<RomData> roms in dict.Values)
|
||||
foreach (List<Rom> roms in dict.Values)
|
||||
{
|
||||
List<RomData> newroms = roms;
|
||||
List<Rom> newroms = roms;
|
||||
if (mergeroms)
|
||||
{
|
||||
newroms = RomTools.Merge(newroms, logger);
|
||||
}
|
||||
|
||||
foreach (RomData rom in newroms)
|
||||
foreach (Rom rom in newroms)
|
||||
{
|
||||
count++;
|
||||
string key = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + rom.Game.ToLowerInvariant();
|
||||
@@ -1484,7 +1484,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> temp = new List<RomData>();
|
||||
List<Rom> temp = new List<Rom>();
|
||||
temp.Add(rom);
|
||||
sortable.Add(key, temp);
|
||||
}
|
||||
@@ -1509,9 +1509,9 @@ namespace SabreTools.Helper
|
||||
/// <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>
|
||||
/// <returns>SortedDictionary bucketed by size and hash</returns>
|
||||
public static SortedDictionary<string, List<RomData>> BucketByHashSize(List<RomData> 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<RomData>> dict = new Dictionary<string, List<RomData>>();
|
||||
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||
dict.Add("key", list);
|
||||
return BucketByHashSize(dict, mergeroms, norename, logger, output);
|
||||
}
|
||||
@@ -1525,9 +1525,9 @@ namespace SabreTools.Helper
|
||||
/// <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>
|
||||
/// <returns>SortedDictionary bucketed by size and hash</returns>
|
||||
public static SortedDictionary<string, List<RomData>> BucketByHashSize(IDictionary<string, List<RomData>> 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<RomData>> sortable = new SortedDictionary<string, List<RomData>>();
|
||||
SortedDictionary<string, List<Rom>> sortable = new SortedDictionary<string, List<Rom>>();
|
||||
long count = 0;
|
||||
|
||||
// If we have a null dict or an empty one, output a new dictionary
|
||||
@@ -1537,15 +1537,15 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Process each all of the roms
|
||||
foreach (List<RomData> roms in dict.Values)
|
||||
foreach (List<Rom> roms in dict.Values)
|
||||
{
|
||||
List<RomData> newroms = roms;
|
||||
List<Rom> newroms = roms;
|
||||
if (mergeroms)
|
||||
{
|
||||
newroms = RomTools.Merge(newroms, logger);
|
||||
}
|
||||
|
||||
foreach (RomData rom in newroms)
|
||||
foreach (Rom rom in newroms)
|
||||
{
|
||||
count++;
|
||||
string key = rom.Size + "-" + rom.CRC; ;
|
||||
@@ -1555,7 +1555,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> temp = new List<RomData>();
|
||||
List<Rom> temp = new List<Rom>();
|
||||
temp.Add(rom);
|
||||
sortable.Add(key, temp);
|
||||
}
|
||||
@@ -1589,7 +1589,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="sha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
||||
/// <param name="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
|
||||
/// <param name="logger">Logging object for console and file output</param>
|
||||
public static void Update(string inputFileName, DatData datdata, string outputDirectory, bool clean, string gamename, string romname,
|
||||
public static void Update(string inputFileName, Dat datdata, string outputDirectory, bool clean, string gamename, string romname,
|
||||
string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger)
|
||||
{
|
||||
// Clean the input string
|
||||
@@ -1620,7 +1620,7 @@ namespace SabreTools.Helper
|
||||
foreach (string file in Directory.EnumerateFiles(inputFileName, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
logger.User("Processing \"" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + "\"");
|
||||
DatData innerDatdata = (DatData)datdata.Clone();
|
||||
Dat innerDatdata = (Dat)datdata.Clone();
|
||||
innerDatdata.Roms = null;
|
||||
innerDatdata = Parse(file, 0, 0, innerDatdata, logger, true, clean);
|
||||
innerDatdata = Filter(innerDatdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, logger);
|
||||
@@ -1658,16 +1658,16 @@ namespace SabreTools.Helper
|
||||
/// <param name="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
|
||||
/// <param name="logger">Logging object for console and file output</param>
|
||||
/// <returns>Returns filtered DatData object</returns>
|
||||
public static DatData Filter(DatData datdata, string gamename, string romname, string romtype, long sgt,
|
||||
public static Dat Filter(Dat datdata, string gamename, string romname, string romtype, long sgt,
|
||||
long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger)
|
||||
{
|
||||
// Now loop through and create a new Rom dictionary using filtered values
|
||||
Dictionary<string, List<RomData>> dict = new Dictionary<string, List<RomData>>();
|
||||
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||
List<string> keys = datdata.Roms.Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<RomData> roms = datdata.Roms[key];
|
||||
foreach (RomData rom in roms)
|
||||
List<Rom> roms = datdata.Roms[key];
|
||||
foreach (Rom rom in roms)
|
||||
{
|
||||
// Filter on nodump status
|
||||
if (nodump == true && !rom.Nodump)
|
||||
@@ -1794,7 +1794,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<RomData> temp = new List<RomData>();
|
||||
List<Rom> temp = new List<Rom>();
|
||||
temp.Add(rom);
|
||||
dict.Add(key, temp);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace SabreTools.Helper
|
||||
/// - Have the ability to strip special (non-ASCII) characters from rom information
|
||||
/// - Add a flag for ignoring roms with blank sizes
|
||||
/// </remarks>
|
||||
public static bool WriteDatfile(DatData datdata, string outDir, Logger logger, bool norename = true, bool stats = false)
|
||||
public static bool WriteDatfile(Dat datdata, string outDir, Logger logger, bool norename = true, bool stats = false)
|
||||
{
|
||||
// Output initial statistics, for kicks
|
||||
if (stats)
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Bucket roms by game name and optionally dedupe
|
||||
SortedDictionary<string, List<RomData>> sortable = DatTools.BucketByGame(datdata.Roms, datdata.MergeRoms, norename, logger);
|
||||
SortedDictionary<string, List<Rom>> sortable = DatTools.BucketByGame(datdata.Roms, datdata.MergeRoms, norename, logger);
|
||||
|
||||
// Now write out to file
|
||||
// If it's empty, use the current folder
|
||||
@@ -61,11 +61,11 @@ namespace SabreTools.Helper
|
||||
int depth = 2, last = -1;
|
||||
string lastgame = null;
|
||||
List<string> splitpath = new List<string>();
|
||||
foreach (List<RomData> roms in sortable.Values)
|
||||
foreach (List<Rom> roms in sortable.Values)
|
||||
{
|
||||
for (int index = 0; index < roms.Count; index++)
|
||||
{
|
||||
RomData rom = roms[index];
|
||||
Rom rom = roms[index];
|
||||
List<string> newsplit = rom.Game.Split('\\').ToList();
|
||||
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
@@ -136,7 +136,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="datdata">DatData object representing DAT information</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
public static bool WriteHeader(StreamWriter sw, DatData datdata, Logger logger)
|
||||
public static bool WriteHeader(StreamWriter sw, Dat datdata, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -244,7 +244,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>The new depth of the tag</returns>
|
||||
public static int WriteStartGame(StreamWriter sw, RomData rom, List<string> newsplit, string lastgame, DatData 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
|
||||
{
|
||||
@@ -303,7 +303,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>The new depth of the tag</returns>
|
||||
public static int WriteEndGame(StreamWriter sw, RomData rom, List<string> splitpath, List<string> newsplit, string lastgame, DatData 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;
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
public static bool WriteRomData(StreamWriter sw, RomData rom, string lastgame, DatData datdata, int depth, Logger logger)
|
||||
public static bool WriteRomData(StreamWriter sw, Rom rom, string lastgame, Dat datdata, int depth, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -505,7 +505,7 @@ namespace SabreTools.Helper
|
||||
/// /// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
public static bool WriteFooter(StreamWriter sw, DatData datdata, int depth, Logger logger)
|
||||
public static bool WriteFooter(StreamWriter sw, Dat datdata, int depth, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -17,9 +17,9 @@ 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 RomData 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)
|
||||
{
|
||||
RomData rom = new RomData
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Name = Path.GetFileName(input),
|
||||
Type = "rom",
|
||||
@@ -74,7 +74,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return new RomData();
|
||||
return new Rom();
|
||||
}
|
||||
|
||||
return rom;
|
||||
@@ -144,19 +144,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<RomData> Merge(List<RomData> inroms, Logger logger)
|
||||
public static List<Rom> Merge(List<Rom> inroms, Logger logger)
|
||||
{
|
||||
// Check for null or blank roms first
|
||||
if (inroms == null || inroms.Count == 0)
|
||||
{
|
||||
return new List<RomData>();
|
||||
return new List<Rom>();
|
||||
}
|
||||
|
||||
// Create output list
|
||||
List<RomData> outroms = new List<RomData>();
|
||||
List<Rom> outroms = new List<Rom>();
|
||||
|
||||
// Then deduplicate them by checking to see if data matches previous saved roms
|
||||
foreach (RomData rom in inroms)
|
||||
foreach (Rom rom in inroms)
|
||||
{
|
||||
// If it's a nodump, add and skip
|
||||
if (rom.Nodump)
|
||||
@@ -170,11 +170,11 @@ namespace SabreTools.Helper
|
||||
{
|
||||
// Check if the rom is a duplicate
|
||||
DupeType dupetype = DupeType.None;
|
||||
RomData savedrom = new RomData();
|
||||
Rom savedrom = new Rom();
|
||||
int pos = -1;
|
||||
for (int i = 0; i < outroms.Count; i++)
|
||||
{
|
||||
RomData lastrom = outroms[i];
|
||||
Rom lastrom = outroms[i];
|
||||
|
||||
// Get the duplicate status
|
||||
dupetype = GetDuplicateStatus(rom, lastrom);
|
||||
@@ -240,9 +240,9 @@ namespace SabreTools.Helper
|
||||
/// <param name="lastrom">Rom to use as a base</param>
|
||||
/// <param name="datdata">DAT to match against</param>
|
||||
/// <returns>List of matched RomData objects</returns>
|
||||
public static List<RomData> GetDuplicates(RomData lastrom, DatData datdata)
|
||||
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata)
|
||||
{
|
||||
List<RomData> output = new List<RomData>();
|
||||
List<Rom> output = new List<Rom>();
|
||||
|
||||
// Check for an empty rom list first
|
||||
if (datdata.Roms == null || datdata.Roms.Count == 0)
|
||||
@@ -251,9 +251,9 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Try to find duplicates
|
||||
foreach (List<RomData> roms in datdata.Roms.Values)
|
||||
foreach (List<Rom> roms in datdata.Roms.Values)
|
||||
{
|
||||
foreach (RomData rom in roms)
|
||||
foreach (Rom rom in roms)
|
||||
{
|
||||
if (IsDuplicate(rom, lastrom))
|
||||
{
|
||||
@@ -271,7 +271,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="rom">Rom to check for duplicate status</param>
|
||||
/// <param name="lastrom">Rom to use as a baseline</param>
|
||||
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
||||
public static bool IsDuplicate(RomData rom, RomData lastrom)
|
||||
public static bool IsDuplicate(Rom rom, Rom lastrom)
|
||||
{
|
||||
bool dupefound = false;
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="rom">Current rom to check</param>
|
||||
/// <param name="lastrom">Last rom to check against</param>
|
||||
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
||||
public static DupeType GetDuplicateStatus(RomData rom, RomData lastrom)
|
||||
public static DupeType GetDuplicateStatus(Rom rom, Rom lastrom)
|
||||
{
|
||||
DupeType output = DupeType.None;
|
||||
|
||||
@@ -350,9 +350,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<RomData> roms, bool norename)
|
||||
public static bool Sort(List<Rom> roms, bool norename)
|
||||
{
|
||||
roms.Sort(delegate (RomData x, RomData y)
|
||||
roms.Sort(delegate (Rom x, Rom y)
|
||||
{
|
||||
if (x.Metadata.SystemID == y.Metadata.SystemID)
|
||||
{
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace SabreTools.Helper
|
||||
{
|
||||
_logger.User("Beginning stat collection for '" + filename + "'");
|
||||
List<String> games = new List<String>();
|
||||
DatData datdata = new DatData();
|
||||
Dat datdata = new Dat();
|
||||
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
||||
SortedDictionary<string, List<RomData>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger, false);
|
||||
SortedDictionary<string, List<Rom>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger, false);
|
||||
|
||||
// Output single DAT stats (if asked)
|
||||
if (_single)
|
||||
@@ -76,7 +76,7 @@ namespace SabreTools.Helper
|
||||
|
||||
// Output total DAT stats
|
||||
if (!_single) { _logger.User(""); }
|
||||
DatData totaldata = new DatData
|
||||
Dat totaldata = new Dat
|
||||
{
|
||||
TotalSize = totalSize,
|
||||
RomCount = totalRom,
|
||||
@@ -102,7 +102,7 @@ Please check the log folder if the stats scrolled offscreen");
|
||||
/// <param name="logger">Logger object for file and console writing</param>
|
||||
/// <param name="recalculate">True if numbers should be recalculated for the DAT, false otherwise (default)</param>
|
||||
/// <param name="game">Number of games to use, -1 means recalculate games (default)</param>
|
||||
public static void OutputStats(DatData datdata, Logger logger, bool recalculate = false, long game = -1)
|
||||
public static void OutputStats(Dat datdata, Logger logger, bool recalculate = false, long game = -1)
|
||||
{
|
||||
if (recalculate)
|
||||
{
|
||||
@@ -116,9 +116,9 @@ Please check the log folder if the stats scrolled offscreen");
|
||||
datdata.NodumpCount = 0;
|
||||
|
||||
// Loop through and add
|
||||
foreach (List<RomData> roms in datdata.Roms.Values)
|
||||
foreach (List<Rom> roms in datdata.Roms.Values)
|
||||
{
|
||||
foreach (RomData rom in roms)
|
||||
foreach (Rom rom in roms)
|
||||
{
|
||||
datdata.RomCount += (rom.Type == "rom" ? 1 : 0);
|
||||
datdata.DiskCount += (rom.Type == "disk" ? 1 : 0);
|
||||
@@ -131,7 +131,7 @@ Please check the log folder if the stats scrolled offscreen");
|
||||
}
|
||||
}
|
||||
|
||||
SortedDictionary<string, List<RomData>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger);
|
||||
SortedDictionary<string, List<Rom>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger);
|
||||
logger.User(@" Uncompressed size: " + Style.GetBytesReadable(datdata.TotalSize) + @"
|
||||
Games found: " + (game == -1 ? newroms.Count : game) + @"
|
||||
Roms found: " + datdata.RomCount + @"
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="outDir">Output directory</param>
|
||||
/// <param name="datdata">DAT information</param>
|
||||
/// <returns>String representing the proper name</returns>
|
||||
public static string CreateOutfileName(string outDir, DatData datdata)
|
||||
public static string CreateOutfileName(string outDir, Dat datdata)
|
||||
{
|
||||
// Double check the outdir for the end delim
|
||||
if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
|
||||
Reference in New Issue
Block a user