mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Rename Rom to File
This commit is contained in:
@@ -19,7 +19,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
try
|
||||
{
|
||||
StreamReader sr = File.OpenText(filename);
|
||||
StreamReader sr = System.IO.File.OpenText(filename);
|
||||
string first = sr.ReadLine();
|
||||
sr.Close();
|
||||
sr.Dispose();
|
||||
@@ -53,7 +53,7 @@ namespace SabreTools.Helper
|
||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
||||
|
||||
// Check if file exists
|
||||
if (!File.Exists(filename))
|
||||
if (!System.IO.File.Exists(filename))
|
||||
{
|
||||
logger.Warning("File '" + filename + "' could not read from!");
|
||||
return null;
|
||||
@@ -95,7 +95,7 @@ namespace SabreTools.Helper
|
||||
// Make sure there's a dictionary to read to
|
||||
if (datdata.Roms == null)
|
||||
{
|
||||
datdata.Roms = new Dictionary<string, List<Rom>>();
|
||||
datdata.Roms = new Dictionary<string, List<File>>();
|
||||
}
|
||||
|
||||
// Now parse the correct type of DAT
|
||||
@@ -130,14 +130,14 @@ namespace SabreTools.Helper
|
||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
||||
|
||||
// Check if file exists
|
||||
if (!File.Exists(filename))
|
||||
if (!System.IO.File.Exists(filename))
|
||||
{
|
||||
logger.Warning("File '" + filename + "' could not read from!");
|
||||
return datdata;
|
||||
}
|
||||
|
||||
// If it does, open a file reader
|
||||
StreamReader sr = new StreamReader(File.OpenRead(filename));
|
||||
StreamReader sr = new StreamReader(System.IO.File.OpenRead(filename));
|
||||
|
||||
bool block = false, superdat = false;
|
||||
string blockname = "", gamename = "", gamedesc = "";
|
||||
@@ -170,7 +170,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
gamename = (clean ? Style.CleanGameName(gamename) : gamename);
|
||||
|
||||
Rom rom = new Rom
|
||||
File rom = new File
|
||||
{
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -328,7 +328,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> templist = new List<Rom>();
|
||||
List<File> templist = new List<File>();
|
||||
templist.Add(rom);
|
||||
datdata.Roms.Add(key, templist);
|
||||
}
|
||||
@@ -457,14 +457,14 @@ namespace SabreTools.Helper
|
||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
||||
|
||||
// Check if file exists
|
||||
if (!File.Exists(filename))
|
||||
if (!System.IO.File.Exists(filename))
|
||||
{
|
||||
logger.Warning("File '" + filename + "' could not read from!");
|
||||
return datdata;
|
||||
}
|
||||
|
||||
// If it does, open a file reader
|
||||
StreamReader sr = new StreamReader(File.OpenRead(filename));
|
||||
StreamReader sr = new StreamReader(System.IO.File.OpenRead(filename));
|
||||
|
||||
string blocktype = "";
|
||||
while (!sr.EndOfStream)
|
||||
@@ -566,7 +566,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
rominfo[3] = (clean ? Style.CleanGameName(rominfo[3]) : rominfo[3]);
|
||||
|
||||
Rom rom = new Rom
|
||||
File rom = new File
|
||||
{
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -616,7 +616,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> templist = new List<Rom>();
|
||||
List<File> templist = new List<File>();
|
||||
templist.Add(rom);
|
||||
datdata.Roms.Add(key, templist);
|
||||
}
|
||||
@@ -677,7 +677,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
tempgame = (clean ? Style.CleanGameName(tempgame) : tempgame);
|
||||
|
||||
Rom rom = new Rom
|
||||
File rom = new File
|
||||
{
|
||||
Type = ItemType.Rom,
|
||||
Name = "null",
|
||||
@@ -702,7 +702,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> temp = new List<Rom>();
|
||||
List<File> temp = new List<File>();
|
||||
temp.Add(rom);
|
||||
datdata.Roms.Add(key, temp);
|
||||
}
|
||||
@@ -1081,7 +1081,7 @@ namespace SabreTools.Helper
|
||||
if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore")
|
||||
{
|
||||
int index = datdata.Roms[key].Count() - 1;
|
||||
Rom lastrom = datdata.Roms[key][index];
|
||||
File lastrom = datdata.Roms[key][index];
|
||||
lastrom.HashData.Size += size;
|
||||
datdata.Roms[key].RemoveAt(index);
|
||||
datdata.Roms[key].Add(lastrom);
|
||||
@@ -1127,7 +1127,7 @@ namespace SabreTools.Helper
|
||||
// Get the new values to add
|
||||
key = size + "-" + crc;
|
||||
|
||||
Rom rom = new Rom
|
||||
File rom = new File
|
||||
{
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -1154,7 +1154,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> newvalue = new List<Rom>();
|
||||
List<File> newvalue = new List<File>();
|
||||
newvalue.Add(rom);
|
||||
datdata.Roms.Add(key, newvalue);
|
||||
}
|
||||
@@ -1186,7 +1186,7 @@ namespace SabreTools.Helper
|
||||
// If we're in cleaning mode, sanitize the game name
|
||||
tempname = (clean ? Style.CleanGameName(tempname.Split(Path.DirectorySeparatorChar)) : tempname);
|
||||
|
||||
Rom rom = new Rom
|
||||
File rom = new File
|
||||
{
|
||||
Type = ItemType.Rom,
|
||||
Name = "null",
|
||||
@@ -1211,7 +1211,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> temp = new List<Rom>();
|
||||
List<File> temp = new List<File>();
|
||||
temp.Add(rom);
|
||||
datdata.Roms.Add(key, temp);
|
||||
}
|
||||
@@ -1312,7 +1312,7 @@ namespace SabreTools.Helper
|
||||
if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore")
|
||||
{
|
||||
int index = datdata.Roms[key].Count() - 1;
|
||||
Rom lastrom = datdata.Roms[key][index];
|
||||
File lastrom = datdata.Roms[key][index];
|
||||
lastrom.HashData.Size += size;
|
||||
datdata.Roms[key].RemoveAt(index);
|
||||
datdata.Roms[key].Add(lastrom);
|
||||
@@ -1367,7 +1367,7 @@ namespace SabreTools.Helper
|
||||
// Get the new values to add
|
||||
key = size + "-" + crc;
|
||||
|
||||
Rom rom = new Rom
|
||||
File rom = new File
|
||||
{
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -1393,7 +1393,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> newvalue = new List<Rom>();
|
||||
List<File> newvalue = new List<File>();
|
||||
newvalue.Add(rom);
|
||||
datdata.Roms.Add(key, newvalue);
|
||||
}
|
||||
@@ -1431,9 +1431,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<Rom>> BucketByGame(List<Rom> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
public static SortedDictionary<string, List<File>> BucketByGame(List<File> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
{
|
||||
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||
Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
|
||||
dict.Add("key", list);
|
||||
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="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<Rom>> BucketByGame(IDictionary<string, List<Rom>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
public static SortedDictionary<string, List<File>> BucketByGame(IDictionary<string, List<File>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
{
|
||||
SortedDictionary<string, List<Rom>> sortable = new SortedDictionary<string, List<Rom>>();
|
||||
SortedDictionary<string, List<File>> sortable = new SortedDictionary<string, List<File>>();
|
||||
long count = 0;
|
||||
|
||||
// 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
|
||||
foreach (string key in dict.Keys)
|
||||
{
|
||||
List<Rom> roms = dict[key];
|
||||
List<File> roms = dict[key];
|
||||
if (mergeroms)
|
||||
{
|
||||
roms = RomTools.Merge(roms, logger);
|
||||
}
|
||||
|
||||
foreach (Rom rom in roms)
|
||||
foreach (File rom in roms)
|
||||
{
|
||||
count++;
|
||||
string newkey = (norename ? ""
|
||||
@@ -1483,7 +1483,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> temp = new List<Rom>();
|
||||
List<File> temp = new List<File>();
|
||||
temp.Add(rom);
|
||||
sortable.Add(newkey, temp);
|
||||
}
|
||||
@@ -1508,9 +1508,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<Rom>> BucketByHashSize(List<Rom> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
public static SortedDictionary<string, List<File>> BucketByHashSize(List<File> list, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
{
|
||||
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||
Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
|
||||
dict.Add("key", list);
|
||||
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="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<Rom>> BucketByHashSize(IDictionary<string, List<Rom>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
public static SortedDictionary<string, List<File>> BucketByHashSize(IDictionary<string, List<File>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||
{
|
||||
SortedDictionary<string, List<Rom>> sortable = new SortedDictionary<string, List<Rom>>();
|
||||
SortedDictionary<string, List<File>> sortable = new SortedDictionary<string, List<File>>();
|
||||
long count = 0;
|
||||
|
||||
// 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
|
||||
foreach (List<Rom> roms in dict.Values)
|
||||
foreach (List<File> roms in dict.Values)
|
||||
{
|
||||
List<Rom> newroms = roms;
|
||||
List<File> newroms = roms;
|
||||
if (mergeroms)
|
||||
{
|
||||
newroms = RomTools.Merge(newroms, logger);
|
||||
}
|
||||
|
||||
foreach (Rom rom in newroms)
|
||||
foreach (File rom in newroms)
|
||||
{
|
||||
count++;
|
||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
||||
@@ -1554,7 +1554,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> temp = new List<Rom>();
|
||||
List<File> temp = new List<File>();
|
||||
temp.Add(rom);
|
||||
sortable.Add(key, temp);
|
||||
}
|
||||
@@ -1627,7 +1627,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (File.Exists(input))
|
||||
else if (System.IO.File.Exists(input))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1687,7 +1687,7 @@ namespace SabreTools.Helper
|
||||
inputFileName = Path.GetFullPath(inputFileName);
|
||||
}
|
||||
|
||||
if (File.Exists(inputFileName))
|
||||
if (System.IO.File.Exists(inputFileName))
|
||||
{
|
||||
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
|
||||
datdata = Parse(inputFileName, 0, 0, datdata, logger, true, clean, softlist, keepext:(datdata.TSV != null));
|
||||
@@ -1756,7 +1756,7 @@ namespace SabreTools.Helper
|
||||
int i = 0;
|
||||
userData = new Dat
|
||||
{
|
||||
Roms = new Dictionary<string, List<Rom>>(),
|
||||
Roms = new Dictionary<string, List<File>>(),
|
||||
MergeRoms = inputDat.MergeRoms,
|
||||
};
|
||||
foreach (string input in inputs)
|
||||
@@ -1771,14 +1771,14 @@ namespace SabreTools.Helper
|
||||
datHeaders.Add((Dat)userData.CloneHeader());
|
||||
|
||||
// Reset the header values so the next can be captured
|
||||
Dictionary<string, List<Rom>> temp = userData.Roms;
|
||||
Dictionary<string, List<File>> temp = userData.Roms;
|
||||
userData = new Dat();
|
||||
userData.Roms = temp;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the output values
|
||||
Dictionary<string, List<Rom>> roms = userData.Roms;
|
||||
Dictionary<string, List<File>> roms = userData.Roms;
|
||||
userData = (Dat)inputDat.CloneHeader();
|
||||
userData.Roms = 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)
|
||||
{
|
||||
// Now loop through and create a new Rom dictionary using filtered values
|
||||
Dictionary<string, List<Rom>> dict = new Dictionary<string, List<Rom>>();
|
||||
Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
|
||||
List<string> keys = datdata.Roms.Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<Rom> roms = datdata.Roms[key];
|
||||
List<File> roms = datdata.Roms[key];
|
||||
for (int i = 0; i < roms.Count; i++)
|
||||
{
|
||||
Rom rom = roms[i];
|
||||
File rom = roms[i];
|
||||
|
||||
// Filter on nodump status
|
||||
if (nodump == true && !rom.Nodump)
|
||||
@@ -1963,7 +1963,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> temp = new List<Rom>();
|
||||
List<File> temp = new List<File>();
|
||||
temp.Add(rom);
|
||||
dict.Add(key, temp);
|
||||
}
|
||||
@@ -2041,11 +2041,11 @@ namespace SabreTools.Helper
|
||||
List<string> keys = userData.Roms.Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<Rom> roms = RomTools.Merge(userData.Roms[key], logger);
|
||||
List<File> roms = RomTools.Merge(userData.Roms[key], logger);
|
||||
|
||||
if (roms != null && roms.Count > 0)
|
||||
{
|
||||
foreach (Rom rom in roms)
|
||||
foreach (File rom in roms)
|
||||
{
|
||||
// No duplicates
|
||||
if ((diff & DiffMode.NoDupes) != 0 || (diff & DiffMode.Individuals) != 0)
|
||||
@@ -2061,7 +2061,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> tl = new List<Rom>();
|
||||
List<File> tl = new List<File>();
|
||||
tl.Add(rom);
|
||||
outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
|
||||
}
|
||||
@@ -2070,7 +2070,7 @@ namespace SabreTools.Helper
|
||||
// Merged no-duplicates DAT
|
||||
if ((diff & DiffMode.NoDupes) != 0)
|
||||
{
|
||||
Rom newrom = rom;
|
||||
File newrom = rom;
|
||||
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||
|
||||
if (outerDiffData.Roms.ContainsKey(key))
|
||||
@@ -2079,7 +2079,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> tl = new List<Rom>();
|
||||
List<File> tl = new List<File>();
|
||||
tl.Add(rom);
|
||||
outerDiffData.Roms.Add(key, tl);
|
||||
}
|
||||
@@ -2092,7 +2092,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
if (rom.Dupe >= DupeType.ExternalHash)
|
||||
{
|
||||
Rom newrom = rom;
|
||||
File newrom = rom;
|
||||
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||
|
||||
if (dupeData.Roms.ContainsKey(key))
|
||||
@@ -2101,7 +2101,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> tl = new List<Rom>();
|
||||
List<File> tl = new List<File>();
|
||||
tl.Add(rom);
|
||||
dupeData.Roms.Add(key, tl);
|
||||
}
|
||||
@@ -2194,11 +2194,11 @@ namespace SabreTools.Helper
|
||||
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<Rom> roms = RomTools.Merge(userData.Roms[key], logger);
|
||||
List<File> roms = RomTools.Merge(userData.Roms[key], logger);
|
||||
|
||||
if (roms != null && roms.Count > 0)
|
||||
{
|
||||
foreach (Rom rom in roms)
|
||||
foreach (File rom in roms)
|
||||
{
|
||||
if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key))
|
||||
{
|
||||
@@ -2206,7 +2206,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Rom> tl = new List<Rom>();
|
||||
List<File> tl = new List<File>();
|
||||
tl.Add(rom);
|
||||
outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
|
||||
}
|
||||
@@ -2256,10 +2256,10 @@ namespace SabreTools.Helper
|
||||
List<string> keys = userData.Roms.Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<Rom> newroms = new List<Rom>();
|
||||
foreach (Rom rom in userData.Roms[key])
|
||||
List<File> newroms = new List<File>();
|
||||
foreach (File rom in userData.Roms[key])
|
||||
{
|
||||
Rom newrom = rom;
|
||||
File newrom = rom;
|
||||
string filename = inputs[newrom.Metadata.SystemID].Split('¬')[0];
|
||||
string rootpath = inputs[newrom.Metadata.SystemID].Split('¬')[1];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user