[Structs] Rename Rom to File

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

View File

@@ -92,7 +92,7 @@ namespace SabreTools
flag = false; flag = false;
break; break;
default: default:
if (File.Exists(temparg) || Directory.Exists(temparg)) if (System.IO.File.Exists(temparg) || Directory.Exists(temparg))
{ {
input = temparg; input = temparg;
} }
@@ -164,7 +164,7 @@ namespace SabreTools
if (_flag) if (_flag)
{ {
// If it's a single file, just check it // If it's a single file, just check it
if (File.Exists(_input)) if (System.IO.File.Exists(_input))
{ {
DetectSkipperAndTransform(_input); DetectSkipperAndTransform(_input);
} }
@@ -183,7 +183,7 @@ namespace SabreTools
else else
{ {
// If it's a single file, just check it // If it's a single file, just check it
if (File.Exists(_input)) if (System.IO.File.Exists(_input))
{ {
ReplaceHeader(_input); ReplaceHeader(_input);
} }
@@ -224,7 +224,7 @@ namespace SabreTools
// Now take care of the header and new output file // Now take care of the header and new output file
string hstr = string.Empty; string hstr = string.Empty;
using (BinaryReader br = new BinaryReader(File.OpenRead(file))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(file)))
{ {
// Extract the header as a string for the database // Extract the header as a string for the database
byte[] hbin = br.ReadBytes(headerSize); byte[] hbin = br.ReadBytes(headerSize);
@@ -248,13 +248,13 @@ namespace SabreTools
Skippers.TransformFile(file, newfile, rule, _logger); Skippers.TransformFile(file, newfile, rule, _logger);
// If the output file doesn't exist, return false // If the output file doesn't exist, return false
if (!File.Exists(newfile)) if (!System.IO.File.Exists(newfile))
{ {
return false; return false;
} }
// 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
Rom rom = RomTools.GetSingleFileInfo(newfile); Helper.File 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
Rom rom = RomTools.GetSingleFileInfo(file); Helper.File 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 = "";

View File

@@ -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 Rom : IComparable, IEquatable<Rom> public struct File : IComparable, IEquatable<File>
{ {
public Machine Machine; public Machine Machine;
public string Name; public string Name;
@@ -64,7 +64,7 @@ namespace SabreTools.Helper
try try
{ {
Rom comp = (Rom)obj; File comp = (File)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(Rom other) public bool Equals(File 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<Rom>> Roms; public Dictionary<string, List<File>> Roms;
// 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,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<File>>(),
UseGame = this.UseGame, UseGame = this.UseGame,
Prefix = this.Prefix, Prefix = this.Prefix,
Postfix = this.Postfix, Postfix = this.Postfix,

View File

@@ -70,7 +70,7 @@ namespace SabreTools.Helper
try try
{ {
_log = new StreamWriter(File.Open(_basepath + _filename, FileMode.OpenOrCreate | FileMode.Append)); _log = new StreamWriter(System.IO.File.Open(_basepath + _filename, FileMode.OpenOrCreate | FileMode.Append));
_log.WriteLine("Logging started " + DateTime.Now); _log.WriteLine("Logging started " + DateTime.Now);
_log.Flush(); _log.Flush();
} }

View File

@@ -58,7 +58,7 @@ namespace SabreTools.Helper
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
try try
{ {
doc.LoadXml(File.ReadAllText(Path.Combine(_remappersPath, mapping + ".xml"))); doc.LoadXml(System.IO.File.ReadAllText(Path.Combine(_remappersPath, mapping + ".xml")));
} }
catch (XmlException ex) catch (XmlException ex)
{ {

View File

@@ -74,7 +74,7 @@ namespace SabreTools.Helper
Rules = new List<SkipperRule>(), Rules = new List<SkipperRule>(),
}; };
if (!File.Exists(filename)) if (!System.IO.File.Exists(filename))
{ {
return skipper; return skipper;
} }
@@ -319,7 +319,7 @@ namespace SabreTools.Helper
SkipperRule skipperRule = new SkipperRule(); SkipperRule skipperRule = new SkipperRule();
// If the file doesn't exist, return a blank skipper rule // If the file doesn't exist, return a blank skipper rule
if (!File.Exists(input)) if (!System.IO.File.Exists(input))
{ {
logger.Error("The file '" + input + "' does not exist so it cannot be tested"); logger.Error("The file '" + input + "' does not exist so it cannot be tested");
return skipperRule; return skipperRule;
@@ -332,7 +332,7 @@ namespace SabreTools.Helper
if (String.IsNullOrEmpty(skippername) || (!String.IsNullOrEmpty(skipper.Name) && skippername.ToLowerInvariant() == skipper.Name.ToLowerInvariant())) if (String.IsNullOrEmpty(skippername) || (!String.IsNullOrEmpty(skipper.Name) && skippername.ToLowerInvariant() == skipper.Name.ToLowerInvariant()))
{ {
// Loop through the rules until one is found that works // Loop through the rules until one is found that works
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
{ {
foreach (SkipperRule rule in skipper.Rules) foreach (SkipperRule rule in skipper.Rules)
{ {
@@ -495,7 +495,7 @@ namespace SabreTools.Helper
bool success = true; bool success = true;
// If the input file doesn't exist, fail // If the input file doesn't exist, fail
if (!File.Exists(input)) if (!System.IO.File.Exists(input))
{ {
logger.Error("I'm sorry but '" + input + "' doesn't exist!"); logger.Error("I'm sorry but '" + input + "' doesn't exist!");
return false; return false;
@@ -521,8 +521,8 @@ namespace SabreTools.Helper
try try
{ {
logger.User("Applying found rule to file '" + input + "'"); logger.User("Applying found rule to file '" + input + "'");
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(output))) using (BinaryWriter bw = new BinaryWriter(System.IO.File.OpenWrite(output)))
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
{ {
// Seek to the beginning offset // Seek to the beginning offset
if (rule.StartOffset == null) if (rule.StartOffset == null)
@@ -619,7 +619,7 @@ namespace SabreTools.Helper
{ {
try try
{ {
File.Delete(output); System.IO.File.Delete(output);
} }
catch catch
{ {
@@ -663,7 +663,7 @@ namespace SabreTools.Helper
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
try try
{ {
doc.LoadXml(File.ReadAllText(System.IO.Path.Combine(Path, skipper + ".xml"))); doc.LoadXml(System.IO.File.ReadAllText(System.IO.Path.Combine(Path, skipper + ".xml")));
} }
catch (XmlException ex) catch (XmlException ex)
{ {
@@ -726,7 +726,7 @@ namespace SabreTools.Helper
public static HeaderType GetFileHeaderType(string input, out int hs, Logger logger) public static HeaderType GetFileHeaderType(string input, out int hs, Logger logger)
{ {
// Open the file in read mode // Open the file in read mode
BinaryReader br = new BinaryReader(File.OpenRead(input)); BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input));
// Extract the first 1024 bytes of the file // Extract the first 1024 bytes of the file
byte[] hbin = br.ReadBytes(1024); byte[] hbin = br.ReadBytes(1024);

View File

@@ -19,14 +19,14 @@ 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, Rom rom) public static void WriteToArchive(string input, string output, File rom)
{ {
string archiveFileName = Path.Combine(output, rom.Machine + ".zip"); string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
System.IO.Compression.ZipArchive outarchive = null; System.IO.Compression.ZipArchive outarchive = null;
try try
{ {
if (!File.Exists(archiveFileName)) if (!System.IO.File.Exists(archiveFileName))
{ {
outarchive = ZipFile.Open(archiveFileName, ZipArchiveMode.Create); outarchive = ZipFile.Open(archiveFileName, ZipArchiveMode.Create);
} }
@@ -35,7 +35,7 @@ namespace SabreTools.Helper
outarchive = ZipFile.Open(archiveFileName, ZipArchiveMode.Update); outarchive = ZipFile.Open(archiveFileName, ZipArchiveMode.Update);
} }
if (File.Exists(input)) if (System.IO.File.Exists(input))
{ {
if (outarchive.Mode == ZipArchiveMode.Create || outarchive.GetEntry(rom.Name) == null) if (outarchive.Mode == ZipArchiveMode.Create || outarchive.GetEntry(rom.Name) == null)
{ {
@@ -69,18 +69,18 @@ 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, Rom rom) public static void WriteToManagedArchive(string input, string output, File rom)
{ {
string archiveFileName = Path.Combine(output, rom.Machine + ".zip"); string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
// Delete an empty file first // Delete an empty file first
if (File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length == 0) if (System.IO.File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length == 0)
{ {
File.Delete(archiveFileName); System.IO.File.Delete(archiveFileName);
} }
// Get if the file should be written out // Get if the file should be written out
bool newfile = File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length != 0; bool newfile = System.IO.File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length != 0;
using (SharpCompress.Archive.Zip.ZipArchive archive = (newfile using (SharpCompress.Archive.Zip.ZipArchive archive = (newfile
? ArchiveFactory.Open(archiveFileName, Options.LookForHeader) as SharpCompress.Archive.Zip.ZipArchive ? ArchiveFactory.Open(archiveFileName, Options.LookForHeader) as SharpCompress.Archive.Zip.ZipArchive
@@ -88,7 +88,7 @@ namespace SabreTools.Helper
{ {
try try
{ {
if (File.Exists(input)) if (System.IO.File.Exists(input))
{ {
archive.AddEntry(rom.Name, input); archive.AddEntry(rom.Name, input);
} }
@@ -105,10 +105,10 @@ namespace SabreTools.Helper
} }
} }
if (File.Exists(archiveFileName + ".tmp")) if (System.IO.File.Exists(archiveFileName + ".tmp"))
{ {
File.Delete(archiveFileName); System.IO.File.Delete(archiveFileName);
File.Move(archiveFileName + ".tmp", archiveFileName); System.IO.File.Move(archiveFileName + ".tmp", archiveFileName);
} }
} }
@@ -172,7 +172,7 @@ namespace SabreTools.Helper
{ {
if (at == ArchiveType.SevenZip && sevenzip != ArchiveScanLevel.External) if (at == ArchiveType.SevenZip && sevenzip != ArchiveScanLevel.External)
{ {
sza = SevenZipArchive.Open(File.OpenRead(input)); sza = SevenZipArchive.Open(System.IO.File.OpenRead(input));
logger.Log("Found archive of type: " + at); logger.Log("Found archive of type: " + at);
// Create the temp directory // Create the temp directory
@@ -189,9 +189,9 @@ namespace SabreTools.Helper
// Create the temp directory // Create the temp directory
Directory.CreateDirectory(tempdir); Directory.CreateDirectory(tempdir);
using (FileStream itemstream = File.OpenRead(input)) using (FileStream itemstream = System.IO.File.OpenRead(input))
{ {
using (FileStream outstream = File.Create(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input)))) using (FileStream outstream = System.IO.File.Create(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input))))
{ {
using (GZipStream gzstream = new GZipStream(itemstream, CompressionMode.Decompress)) using (GZipStream gzstream = new GZipStream(itemstream, CompressionMode.Decompress))
{ {
@@ -203,7 +203,7 @@ namespace SabreTools.Helper
} }
else else
{ {
reader = ReaderFactory.Open(File.OpenRead(input)); reader = ReaderFactory.Open(System.IO.File.OpenRead(input));
logger.Log("Found archive of type: " + at); logger.Log("Found archive of type: " + at);
if ((at == ArchiveType.Zip && zip != ArchiveScanLevel.External) || if ((at == ArchiveType.Zip && zip != ArchiveScanLevel.External) ||
@@ -265,7 +265,7 @@ namespace SabreTools.Helper
IReader reader = null; IReader reader = null;
try try
{ {
reader = ReaderFactory.Open(File.OpenRead(input)); reader = ReaderFactory.Open(System.IO.File.OpenRead(input));
if (at == ArchiveType.Zip || at == ArchiveType.SevenZip || at == ArchiveType.Rar) if (at == ArchiveType.Zip || at == ArchiveType.SevenZip || at == ArchiveType.Rar)
{ {
@@ -291,9 +291,9 @@ namespace SabreTools.Helper
// Dispose the original reader // Dispose the original reader
reader.Dispose(); reader.Dispose();
using(FileStream itemstream = File.OpenRead(input)) using(FileStream itemstream = System.IO.File.OpenRead(input))
{ {
using (FileStream outstream = File.Create(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input)))) using (FileStream outstream = System.IO.File.Create(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input))))
{ {
using (GZipStream gzstream = new GZipStream(itemstream, CompressionMode.Decompress)) using (GZipStream gzstream = new GZipStream(itemstream, CompressionMode.Decompress))
{ {
@@ -333,7 +333,7 @@ namespace SabreTools.Helper
// First get the archive types // First get the archive types
ArchiveType? iat = GetCurrentArchiveType(inputArchive, logger); ArchiveType? iat = GetCurrentArchiveType(inputArchive, logger);
ArchiveType? oat = (File.Exists(outputArchive) ? GetCurrentArchiveType(outputArchive, logger) : ArchiveType.Zip); ArchiveType? oat = (System.IO.File.Exists(outputArchive) ? GetCurrentArchiveType(outputArchive, logger) : ArchiveType.Zip);
// If we got back null (or the output is not a Zipfile), then it's not an archive, so we we return // If we got back null (or the output is not a Zipfile), then it's not an archive, so we we return
if (iat == null || (oat == null || oat != ArchiveType.Zip) || inputArchive == outputArchive) if (iat == null || (oat == null || oat != ArchiveType.Zip) || inputArchive == outputArchive)
@@ -345,7 +345,7 @@ namespace SabreTools.Helper
System.IO.Compression.ZipArchive outarchive = null; System.IO.Compression.ZipArchive outarchive = null;
try try
{ {
reader = ReaderFactory.Open(File.OpenRead(inputArchive)); reader = ReaderFactory.Open(System.IO.File.OpenRead(inputArchive));
if (iat == ArchiveType.Zip || iat == ArchiveType.SevenZip || iat == ArchiveType.Rar) if (iat == ArchiveType.Zip || iat == ArchiveType.SevenZip || iat == ArchiveType.Rar)
{ {
@@ -354,7 +354,7 @@ namespace SabreTools.Helper
logger.Log("Current entry name: '" + reader.Entry.Key + "'"); logger.Log("Current entry name: '" + reader.Entry.Key + "'");
if (reader.Entry != null && reader.Entry.Key.Contains(sourceEntryName)) if (reader.Entry != null && reader.Entry.Key.Contains(sourceEntryName))
{ {
if (!File.Exists(outputArchive)) if (!System.IO.File.Exists(outputArchive))
{ {
outarchive = ZipFile.Open(outputArchive, ZipArchiveMode.Create); outarchive = ZipFile.Open(outputArchive, ZipArchiveMode.Create);
} }
@@ -407,7 +407,7 @@ namespace SabreTools.Helper
// First get the archive types // First get the archive types
ArchiveType? iat = GetCurrentArchiveType(inputArchive, logger); ArchiveType? iat = GetCurrentArchiveType(inputArchive, logger);
ArchiveType? oat = (File.Exists(outputArchive) ? GetCurrentArchiveType(outputArchive, logger) : ArchiveType.Zip); ArchiveType? oat = (System.IO.File.Exists(outputArchive) ? GetCurrentArchiveType(outputArchive, logger) : ArchiveType.Zip);
// If we got back null (or the output is not a Zipfile), then it's not an archive, so we we return // If we got back null (or the output is not a Zipfile), then it's not an archive, so we we return
if (iat == null || (oat == null || oat != ArchiveType.Zip) || inputArchive == outputArchive) if (iat == null || (oat == null || oat != ArchiveType.Zip) || inputArchive == outputArchive)
@@ -417,7 +417,7 @@ namespace SabreTools.Helper
try try
{ {
using (IReader reader = ReaderFactory.Open(File.OpenRead(inputArchive))) using (IReader reader = ReaderFactory.Open(System.IO.File.OpenRead(inputArchive)))
{ {
if (iat == ArchiveType.Zip || iat == ArchiveType.SevenZip || iat == ArchiveType.Rar) if (iat == ArchiveType.Zip || iat == ArchiveType.SevenZip || iat == ArchiveType.Rar)
{ {
@@ -427,7 +427,7 @@ namespace SabreTools.Helper
if (reader.Entry != null && reader.Entry.Key.Contains(sourceEntryName)) if (reader.Entry != null && reader.Entry.Key.Contains(sourceEntryName))
{ {
// Get if the file should be written out // Get if the file should be written out
bool newfile = File.Exists(outputArchive) && new FileInfo(outputArchive).Length != 0; bool newfile = System.IO.File.Exists(outputArchive) && new FileInfo(outputArchive).Length != 0;
using (SharpCompress.Archive.Zip.ZipArchive archive = (newfile using (SharpCompress.Archive.Zip.ZipArchive archive = (newfile
? ArchiveFactory.Open(outputArchive, Options.LookForHeader) as SharpCompress.Archive.Zip.ZipArchive ? ArchiveFactory.Open(outputArchive, Options.LookForHeader) as SharpCompress.Archive.Zip.ZipArchive
@@ -447,10 +447,10 @@ namespace SabreTools.Helper
} }
} }
if (File.Exists(outputArchive + ".tmp")) if (System.IO.File.Exists(outputArchive + ".tmp"))
{ {
File.Delete(outputArchive); System.IO.File.Delete(outputArchive);
File.Move(outputArchive + ".tmp", outputArchive); System.IO.File.Move(outputArchive + ".tmp", outputArchive);
} }
success = true; success = true;
@@ -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<Rom> GetArchiveFileInfo(string input, Logger logger) public static List<File> GetArchiveFileInfo(string input, Logger logger)
{ {
List<Rom> roms = new List<Rom>(); List<File> roms = new List<File>();
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)
{ {
Rom possibleTgz = GetTorrentGZFileInfo(input, logger); File 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)
@@ -512,7 +512,7 @@ namespace SabreTools.Helper
if (at == ArchiveType.GZip) if (at == ArchiveType.GZip)
{ {
// Get the CRC and size from the file // Get the CRC and size from the file
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
{ {
br.BaseStream.Seek(-8, SeekOrigin.End); br.BaseStream.Seek(-8, SeekOrigin.End);
byte[] headercrc = br.ReadBytes(4); byte[] headercrc = br.ReadBytes(4);
@@ -522,7 +522,7 @@ namespace SabreTools.Helper
} }
} }
reader = ReaderFactory.Open(File.OpenRead(input)); reader = ReaderFactory.Open(System.IO.File.OpenRead(input));
if (at != ArchiveType.Tar) if (at != ArchiveType.Tar)
{ {
@@ -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 Rom roms.Add(new File
{ {
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 Rom GetTorrentGZFileInfo(string input, Logger logger) public static File 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 Rom(); return new File();
} }
// 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 Rom(); return new File();
} }
// Get the Romba-specific header data // Get the Romba-specific header data
@@ -594,7 +594,7 @@ namespace SabreTools.Helper
byte[] headermd5; // MD5 byte[] headermd5; // MD5
byte[] headercrc; // CRC byte[] headercrc; // CRC
byte[] headersz; // Int64 size byte[] headersz; // Int64 size
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
{ {
header = br.ReadBytes(12); header = br.ReadBytes(12);
headermd5 = br.ReadBytes(16); headermd5 = br.ReadBytes(16);
@@ -610,7 +610,7 @@ namespace SabreTools.Helper
} }
if (!correct) if (!correct)
{ {
return new Rom(); return new File();
} }
// 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);
Rom rom = new Rom File rom = new File
{ {
Type = ItemType.Rom, Type = ItemType.Rom,
Machine = new Machine Machine = new Machine
@@ -650,7 +650,7 @@ namespace SabreTools.Helper
public static bool WriteTorrentGZ(string input, string outdir, bool romba, Logger logger) public static bool WriteTorrentGZ(string input, string outdir, bool romba, Logger logger)
{ {
// Check that the input file exists // Check that the input file exists
if (!File.Exists(input)) if (!System.IO.File.Exists(input))
{ {
logger.Warning("File " + input + " does not exist!"); logger.Warning("File " + input + " does not exist!");
return false; return false;
@@ -665,12 +665,12 @@ 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
Rom rom = RomTools.GetSingleFileInfo(input); File 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");
using (FileStream inputstream = new FileStream(input, FileMode.Open)) using (FileStream inputstream = new FileStream(input, FileMode.Open))
using (GZipStream output = new GZipStream(File.Open(outfile, FileMode.Create, FileAccess.Write), CompressionMode.Compress)) using (GZipStream output = new GZipStream(System.IO.File.Open(outfile, FileMode.Create, FileAccess.Write), CompressionMode.Compress))
{ {
inputstream.CopyTo(output); inputstream.CopyTo(output);
} }
@@ -678,7 +678,7 @@ namespace SabreTools.Helper
// Now that it's ready, inject the header info // Now that it's ready, inject the header info
using (BinaryWriter sw = new BinaryWriter(new MemoryStream())) using (BinaryWriter sw = new BinaryWriter(new MemoryStream()))
{ {
using (BinaryReader br = new BinaryReader(File.OpenRead(outfile))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(outfile)))
{ {
// Write standard header and TGZ info // Write standard header and TGZ info
byte[] data = Constants.TorrentGZHeader byte[] data = Constants.TorrentGZHeader
@@ -698,7 +698,7 @@ namespace SabreTools.Helper
} }
} }
using (BinaryWriter bw = new BinaryWriter(File.Open(outfile, FileMode.Create))) using (BinaryWriter bw = new BinaryWriter(System.IO.File.Open(outfile, FileMode.Create)))
{ {
// Now write the new file over the original // Now write the new file over the original
sw.BaseStream.Seek(0, SeekOrigin.Begin); sw.BaseStream.Seek(0, SeekOrigin.Begin);
@@ -719,12 +719,12 @@ namespace SabreTools.Helper
try try
{ {
File.Move(outfile, Path.Combine(outdir, Path.GetFileName(outfile))); System.IO.File.Move(outfile, Path.Combine(outdir, Path.GetFileName(outfile)));
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.Warning(ex.ToString()); logger.Warning(ex.ToString());
File.Delete(outfile); System.IO.File.Delete(outfile);
} }
} }
@@ -754,7 +754,7 @@ namespace SabreTools.Helper
try try
{ {
byte[] magic = new byte[8]; byte[] magic = new byte[8];
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
{ {
magic = br.ReadBytes(8); magic = br.ReadBytes(8);
} }

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Helper
public static void EnsureDatabase(string db, string connectionString) public static void EnsureDatabase(string db, string connectionString)
{ {
// Make sure the file exists // Make sure the file exists
if (!File.Exists(db)) if (!System.IO.File.Exists(db))
{ {
SqliteConnection.CreateFile(db); SqliteConnection.CreateFile(db);
} }

View File

@@ -19,7 +19,7 @@ namespace SabreTools.Helper
{ {
try try
{ {
StreamReader sr = File.OpenText(filename); StreamReader sr = System.IO.File.OpenText(filename);
string first = sr.ReadLine(); string first = sr.ReadLine();
sr.Close(); sr.Close();
sr.Dispose(); sr.Dispose();
@@ -53,7 +53,7 @@ namespace SabreTools.Helper
logger.Log("Attempting to read file: \"" + filename + "\""); logger.Log("Attempting to read file: \"" + filename + "\"");
// Check if file exists // Check if file exists
if (!File.Exists(filename)) if (!System.IO.File.Exists(filename))
{ {
logger.Warning("File '" + filename + "' could not read from!"); logger.Warning("File '" + filename + "' could not read from!");
return null; return null;
@@ -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.Roms == null) 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 // Now parse the correct type of DAT
@@ -130,14 +130,14 @@ namespace SabreTools.Helper
logger.Log("Attempting to read file: \"" + filename + "\""); logger.Log("Attempting to read file: \"" + filename + "\"");
// Check if file exists // Check if file exists
if (!File.Exists(filename)) if (!System.IO.File.Exists(filename))
{ {
logger.Warning("File '" + filename + "' could not read from!"); logger.Warning("File '" + filename + "' could not read from!");
return datdata; return datdata;
} }
// If it does, open a file reader // 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; bool block = false, superdat = false;
string blockname = "", gamename = "", gamedesc = ""; string blockname = "", gamename = "", gamedesc = "";
@@ -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);
Rom rom = new Rom File rom = new File
{ {
Machine = new Machine Machine = new Machine
{ {
@@ -328,7 +328,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> templist = new List<Rom>(); List<File> templist = new List<File>();
templist.Add(rom); templist.Add(rom);
datdata.Roms.Add(key, templist); datdata.Roms.Add(key, templist);
} }
@@ -457,14 +457,14 @@ namespace SabreTools.Helper
logger.Log("Attempting to read file: \"" + filename + "\""); logger.Log("Attempting to read file: \"" + filename + "\"");
// Check if file exists // Check if file exists
if (!File.Exists(filename)) if (!System.IO.File.Exists(filename))
{ {
logger.Warning("File '" + filename + "' could not read from!"); logger.Warning("File '" + filename + "' could not read from!");
return datdata; return datdata;
} }
// If it does, open a file reader // 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 = ""; string blocktype = "";
while (!sr.EndOfStream) while (!sr.EndOfStream)
@@ -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]);
Rom rom = new Rom File rom = new File
{ {
Machine = new Machine Machine = new Machine
{ {
@@ -616,7 +616,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> templist = new List<Rom>(); List<File> templist = new List<File>();
templist.Add(rom); templist.Add(rom);
datdata.Roms.Add(key, templist); datdata.Roms.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);
Rom rom = new Rom File rom = new File
{ {
Type = ItemType.Rom, Type = ItemType.Rom,
Name = "null", Name = "null",
@@ -702,7 +702,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<File> temp = new List<File>();
temp.Add(rom); temp.Add(rom);
datdata.Roms.Add(key, temp); datdata.Roms.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.Roms[key].Count() - 1; int index = datdata.Roms[key].Count() - 1;
Rom lastrom = datdata.Roms[key][index]; File lastrom = datdata.Roms[key][index];
lastrom.HashData.Size += size; lastrom.HashData.Size += size;
datdata.Roms[key].RemoveAt(index); datdata.Roms[key].RemoveAt(index);
datdata.Roms[key].Add(lastrom); datdata.Roms[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;
Rom rom = new Rom File rom = new File
{ {
Machine = new Machine Machine = new Machine
{ {
@@ -1154,7 +1154,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> newvalue = new List<Rom>(); List<File> newvalue = new List<File>();
newvalue.Add(rom); newvalue.Add(rom);
datdata.Roms.Add(key, newvalue); datdata.Roms.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);
Rom rom = new Rom File rom = new File
{ {
Type = ItemType.Rom, Type = ItemType.Rom,
Name = "null", Name = "null",
@@ -1211,7 +1211,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<File> temp = new List<File>();
temp.Add(rom); temp.Add(rom);
datdata.Roms.Add(key, temp); datdata.Roms.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.Roms[key].Count() - 1; int index = datdata.Roms[key].Count() - 1;
Rom lastrom = datdata.Roms[key][index]; File lastrom = datdata.Roms[key][index];
lastrom.HashData.Size += size; lastrom.HashData.Size += size;
datdata.Roms[key].RemoveAt(index); datdata.Roms[key].RemoveAt(index);
datdata.Roms[key].Add(lastrom); datdata.Roms[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;
Rom rom = new Rom File rom = new File
{ {
Machine = new Machine Machine = new Machine
{ {
@@ -1393,7 +1393,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> newvalue = new List<Rom>(); List<File> newvalue = new List<File>();
newvalue.Add(rom); newvalue.Add(rom);
datdata.Roms.Add(key, newvalue); 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="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<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); 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<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; 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<Rom> roms = dict[key]; List<File> roms = dict[key];
if (mergeroms) if (mergeroms)
{ {
roms = RomTools.Merge(roms, logger); roms = RomTools.Merge(roms, logger);
} }
foreach (Rom rom in roms) foreach (File rom in roms)
{ {
count++; count++;
string newkey = (norename ? "" string newkey = (norename ? ""
@@ -1483,7 +1483,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<File> temp = new List<File>();
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<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); 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<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; 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<Rom> roms in dict.Values) foreach (List<File> roms in dict.Values)
{ {
List<Rom> newroms = roms; List<File> newroms = roms;
if (mergeroms) if (mergeroms)
{ {
newroms = RomTools.Merge(newroms, logger); newroms = RomTools.Merge(newroms, logger);
} }
foreach (Rom rom in newroms) foreach (File 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<Rom> temp = new List<Rom>(); List<File> temp = new List<File>();
temp.Add(rom); temp.Add(rom);
sortable.Add(key, temp); sortable.Add(key, temp);
} }
@@ -1627,7 +1627,7 @@ namespace SabreTools.Helper
} }
} }
} }
else if (File.Exists(input)) else if (System.IO.File.Exists(input))
{ {
try try
{ {
@@ -1687,7 +1687,7 @@ namespace SabreTools.Helper
inputFileName = Path.GetFullPath(inputFileName); inputFileName = Path.GetFullPath(inputFileName);
} }
if (File.Exists(inputFileName)) if (System.IO.File.Exists(inputFileName))
{ {
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\""); logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
datdata = Parse(inputFileName, 0, 0, datdata, logger, true, clean, softlist, keepext:(datdata.TSV != null)); datdata = Parse(inputFileName, 0, 0, datdata, logger, true, clean, softlist, keepext:(datdata.TSV != null));
@@ -1756,7 +1756,7 @@ namespace SabreTools.Helper
int i = 0; int i = 0;
userData = new Dat userData = new Dat
{ {
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<File>>(),
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<Rom>> temp = userData.Roms; Dictionary<string, List<File>> temp = userData.Roms;
userData = new Dat(); userData = new Dat();
userData.Roms = temp; userData.Roms = temp;
} }
} }
// Set the output values // Set the output values
Dictionary<string, List<Rom>> roms = userData.Roms; Dictionary<string, List<File>> roms = userData.Roms;
userData = (Dat)inputDat.CloneHeader(); userData = (Dat)inputDat.CloneHeader();
userData.Roms = roms; 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) 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<Rom>> dict = new Dictionary<string, List<Rom>>(); Dictionary<string, List<File>> dict = new Dictionary<string, List<File>>();
List<string> keys = datdata.Roms.Keys.ToList(); List<string> keys = datdata.Roms.Keys.ToList();
foreach (string key in keys) 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++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; File 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<Rom> temp = new List<Rom>(); List<File> temp = new List<File>();
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.Roms.Keys.ToList(); List<string> keys = userData.Roms.Keys.ToList();
foreach (string key in keys) 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) if (roms != null && roms.Count > 0)
{ {
foreach (Rom rom in roms) foreach (File 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<Rom> tl = new List<Rom>(); List<File> tl = new List<File>();
tl.Add(rom); tl.Add(rom);
outDats[rom.Metadata.SystemID].Roms.Add(key, tl); outDats[rom.Metadata.SystemID].Roms.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)
{ {
Rom newrom = rom; File 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.Roms.ContainsKey(key)) if (outerDiffData.Roms.ContainsKey(key))
@@ -2079,7 +2079,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> tl = new List<Rom>(); List<File> tl = new List<File>();
tl.Add(rom); tl.Add(rom);
outerDiffData.Roms.Add(key, tl); outerDiffData.Roms.Add(key, tl);
} }
@@ -2092,7 +2092,7 @@ namespace SabreTools.Helper
{ {
if (rom.Dupe >= DupeType.ExternalHash) if (rom.Dupe >= DupeType.ExternalHash)
{ {
Rom newrom = rom; File 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.Roms.ContainsKey(key)) if (dupeData.Roms.ContainsKey(key))
@@ -2101,7 +2101,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> tl = new List<Rom>(); List<File> tl = new List<File>();
tl.Add(rom); tl.Add(rom);
dupeData.Roms.Add(key, tl); dupeData.Roms.Add(key, tl);
} }
@@ -2194,11 +2194,11 @@ namespace SabreTools.Helper
foreach (string key in keys) 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) if (roms != null && roms.Count > 0)
{ {
foreach (Rom rom in roms) foreach (File rom in roms)
{ {
if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key)) if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key))
{ {
@@ -2206,7 +2206,7 @@ namespace SabreTools.Helper
} }
else else
{ {
List<Rom> tl = new List<Rom>(); List<File> tl = new List<File>();
tl.Add(rom); tl.Add(rom);
outDats[rom.Metadata.SystemID].Roms.Add(key, tl); outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
} }
@@ -2256,10 +2256,10 @@ namespace SabreTools.Helper
List<string> keys = userData.Roms.Keys.ToList(); List<string> keys = userData.Roms.Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<Rom> newroms = new List<Rom>(); List<File> newroms = new List<File>();
foreach (Rom rom in userData.Roms[key]) foreach (File rom in userData.Roms[key])
{ {
Rom newrom = rom; File 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];

View File

@@ -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<Rom>> sortable = DatTools.BucketByGame(datdata.Roms, datdata.MergeRoms, norename, logger); SortedDictionary<string, List<File>> sortable = DatTools.BucketByGame(datdata.Roms, 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
@@ -85,7 +85,7 @@ namespace SabreTools.Helper
try try
{ {
FileStream fs = File.Create(outfile); FileStream fs = System.IO.File.Create(outfile);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
// Write out the header // Write out the header
@@ -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<Rom> roms in sortable.Values) foreach (List<File> roms in sortable.Values)
{ {
for (int index = 0; index < roms.Count; index++) for (int index = 0; index < roms.Count; index++)
{ {
Rom rom = roms[index]; File 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, Rom rom, List<string> newsplit, string lastgame, Dat datdata, int depth, int last, Logger logger) public static int WriteStartGame(StreamWriter sw, File 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, Rom rom, List<string> splitpath, List<string> newsplit, string lastgame, Dat datdata, int depth, out int last, Logger logger) 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)
{ {
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, Rom rom, string lastgame, Dat datdata, int depth, Logger logger) public static bool WriteRomData(StreamWriter sw, File rom, string lastgame, Dat datdata, int depth, Logger logger)
{ {
try try
{ {
@@ -619,7 +619,7 @@ namespace SabreTools.Helper
{ {
try try
{ {
File.Delete(file); System.IO.File.Delete(file);
} }
catch { } catch { }
} }
@@ -643,14 +643,14 @@ namespace SabreTools.Helper
public static void RemoveBytesFromFile(string input, string output, long bytesToRemoveFromHead, long bytesToRemoveFromTail) public static void RemoveBytesFromFile(string input, string output, long bytesToRemoveFromHead, long bytesToRemoveFromTail)
{ {
// If any of the inputs are invalid, skip // If any of the inputs are invalid, skip
if (!File.Exists(input) || new FileInfo(input).Length <= (bytesToRemoveFromHead + bytesToRemoveFromTail)) if (!System.IO.File.Exists(input) || new FileInfo(input).Length <= (bytesToRemoveFromHead + bytesToRemoveFromTail))
{ {
return; return;
} }
// Read the input file and write to the fail // Read the input file and write to the fail
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(output))) using (BinaryWriter bw = new BinaryWriter(System.IO.File.OpenWrite(output)))
{ {
int bufferSize = 1024; int bufferSize = 1024;
long adjustedLength = br.BaseStream.Length - bytesToRemoveFromTail; long adjustedLength = br.BaseStream.Length - bytesToRemoveFromTail;
@@ -708,13 +708,13 @@ namespace SabreTools.Helper
public static void AppendBytesToFile(string input, string output, byte[] bytesToAddToHead, byte[] bytesToAddToTail) public static void AppendBytesToFile(string input, string output, byte[] bytesToAddToHead, byte[] bytesToAddToTail)
{ {
// If any of the inputs are invalid, skip // If any of the inputs are invalid, skip
if (!File.Exists(input)) if (!System.IO.File.Exists(input))
{ {
return; return;
} }
using (BinaryReader br = new BinaryReader(File.OpenRead(input))) using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(input)))
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(output))) using (BinaryWriter bw = new BinaryWriter(System.IO.File.OpenWrite(output)))
{ {
if (bytesToAddToHead.Count() > 0) if (bytesToAddToHead.Count() > 0)
{ {
@@ -751,13 +751,13 @@ namespace SabreTools.Helper
/// <param name="output">Output filename</param> /// <param name="output">Output filename</param>
public static void CopyFileToNewLocation(string input, string output) public static void CopyFileToNewLocation(string input, string output)
{ {
if (File.Exists(input) && !File.Exists(output)) if (System.IO.File.Exists(input) && !System.IO.File.Exists(output))
{ {
if (!Directory.Exists(Path.GetDirectoryName(output))) if (!Directory.Exists(Path.GetDirectoryName(output)))
{ {
Directory.CreateDirectory(Path.GetDirectoryName(output)); Directory.CreateDirectory(Path.GetDirectoryName(output));
} }
File.Copy(input, output); System.IO.File.Copy(input, output);
} }
} }
} }

View File

@@ -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 Rom GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0) public static File GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0)
{ {
// Add safeguard if file doesn't exist // Add safeguard if file doesn't exist
if (!File.Exists(input)) if (!System.IO.File.Exists(input))
{ {
return new Rom(); return new File();
} }
Rom rom = new Rom File rom = new File
{ {
Name = Path.GetFileName(input), Name = Path.GetFileName(input),
Type = ItemType.Rom, Type = ItemType.Rom,
@@ -44,7 +44,7 @@ namespace SabreTools.Helper
using (Crc32 crc = new Crc32()) using (Crc32 crc = new Crc32())
using (MD5 md5 = MD5.Create()) using (MD5 md5 = MD5.Create())
using (SHA1 sha1 = SHA1.Create()) using (SHA1 sha1 = SHA1.Create())
using (FileStream fs = File.OpenRead(input)) using (FileStream fs = System.IO.File.OpenRead(input))
{ {
// Seek to the starting position, if one is set // Seek to the starting position, if one is set
if (offset > 0) if (offset > 0)
@@ -84,7 +84,7 @@ namespace SabreTools.Helper
} }
catch (IOException) catch (IOException)
{ {
return new Rom(); return new File();
} }
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<Rom> Merge(List<Rom> inroms, Logger logger) public static List<File> Merge(List<File> 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<Rom>(); return new List<File>();
} }
// Create output list // Create output list
List<Rom> outroms = new List<Rom>(); List<File> outroms = new List<File>();
// Then deduplicate them by checking to see if data matches previous saved roms // Then deduplicate them by checking to see if data matches previous saved roms
foreach (Rom rom in inroms) foreach (File rom in inroms)
{ {
// If it's a nodump, add and skip // If 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;
Rom savedrom = new Rom(); File savedrom = new File();
int pos = -1; int pos = -1;
for (int i = 0; i < outroms.Count; i++) for (int i = 0; i < outroms.Count; i++)
{ {
Rom lastrom = outroms[i]; File 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<Rom> GetDuplicates(Rom lastrom, Dat datdata, Logger logger, bool remove = false) public static List<File> GetDuplicates(File lastrom, Dat datdata, Logger logger, bool remove = false)
{ {
List<Rom> output = new List<Rom>(); List<File> output = new List<File>();
// Check for an empty rom list first // Check for an empty rom list first
if (datdata.Roms == null || datdata.Roms.Count == 0) if (datdata.Roms == null || datdata.Roms.Count == 0)
@@ -208,9 +208,9 @@ namespace SabreTools.Helper
List<string> keys = datdata.Roms.Keys.ToList(); List<string> keys = datdata.Roms.Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<Rom> roms = datdata.Roms[key]; List<File> roms = datdata.Roms[key];
List<Rom> left = new List<Rom>(); List<File> left = new List<File>();
foreach (Rom rom in roms) foreach (File 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(Rom rom, Rom lastrom, Logger logger) public static bool IsDuplicate(File rom, File 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(Rom rom, Rom lastrom, Logger logger) public static DupeType GetDuplicateStatus(File rom, File 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<Rom> roms, bool norename) public static bool Sort(List<File> roms, bool norename)
{ {
roms.Sort(delegate (Rom x, Rom y) roms.Sort(delegate (File x, File y)
{ {
if (x.Metadata.SystemID == y.Metadata.SystemID) if (x.Metadata.SystemID == y.Metadata.SystemID)
{ {

View File

@@ -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<Rom>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger, false); SortedDictionary<string, List<File>> newroms = DatTools.BucketByGame(datdata.Roms, 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<Rom> roms in datdata.Roms.Values) foreach (List<File> roms in datdata.Roms.Values)
{ {
foreach (Rom rom in roms) foreach (File 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<Rom>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger, false); SortedDictionary<string, List<File>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger, false);
if (datdata.TotalSize < 0) if (datdata.TotalSize < 0)
{ {
datdata.TotalSize = Int64.MaxValue + datdata.TotalSize; datdata.TotalSize = Int64.MaxValue + datdata.TotalSize;

View File

@@ -71,7 +71,7 @@ namespace SabreTools
public bool Start() public bool Start()
{ {
// Double check to see what it needs to be named // Double check to see what it needs to be named
_basePath = (_inputs.Count > 0 ? (File.Exists(_inputs[0]) ? _inputs[0] : _inputs[0] + Path.DirectorySeparatorChar) : ""); _basePath = (_inputs.Count > 0 ? (System.IO.File.Exists(_inputs[0]) ? _inputs[0] : _inputs[0] + Path.DirectorySeparatorChar) : "");
_basePath = (_basePath != "" ? Path.GetFullPath(_basePath) : ""); _basePath = (_basePath != "" ? Path.GetFullPath(_basePath) : "");
// If the description is defined but not the name, set the name from the description // If the description is defined but not the name, set the name from the description
@@ -115,7 +115,7 @@ namespace SabreTools
else else
{ {
// Create and open the output file for writing // Create and open the output file for writing
FileStream fs = File.Create(Style.CreateOutfileName(Environment.CurrentDirectory, _datdata)); FileStream fs = System.IO.File.Create(Style.CreateOutfileName(Environment.CurrentDirectory, _datdata));
sw = new StreamWriter(fs, Encoding.UTF8); sw = new StreamWriter(fs, Encoding.UTF8);
sw.AutoFlush = true; sw.AutoFlush = true;
} }
@@ -128,11 +128,11 @@ namespace SabreTools
foreach (string path in _inputs) foreach (string path in _inputs)
{ {
// Set local paths and vars // Set local paths and vars
_basePath = (File.Exists(path) ? path : path + Path.DirectorySeparatorChar); _basePath = (System.IO.File.Exists(path) ? path : path + Path.DirectorySeparatorChar);
_basePath = Path.GetFullPath(_basePath); _basePath = Path.GetFullPath(_basePath);
// This is where the main loop would go // This is where the main loop would go
if (File.Exists(_basePath)) if (System.IO.File.Exists(_basePath))
{ {
lastparent = ProcessPossibleArchive(_basePath, sw, lastparent); lastparent = ProcessPossibleArchive(_basePath, sw, lastparent);
} }
@@ -152,7 +152,7 @@ namespace SabreTools
{ {
if (_datdata.Type != "SuperDAT") if (_datdata.Type != "SuperDAT")
{ {
_basePath = (File.Exists(item) ? item : item + Path.DirectorySeparatorChar); _basePath = (System.IO.File.Exists(item) ? item : item + Path.DirectorySeparatorChar);
_basePath = Path.GetFullPath(_basePath); _basePath = Path.GetFullPath(_basePath);
} }
@@ -170,7 +170,7 @@ namespace SabreTools
if (!items) if (!items)
{ {
string actualroot = item.Remove(0, basePathBackup.Length); string actualroot = item.Remove(0, basePathBackup.Length);
Rom rom = new Rom Helper.File rom = new Helper.File
{ {
Name = "null", Name = "null",
Machine = new Machine Machine = new Machine
@@ -197,7 +197,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
_datdata.Roms.Add(key, temp); _datdata.Roms.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);
Rom rom = new Rom Helper.File rom = new Helper.File
{ {
Name = "null", Name = "null",
Machine = new Machine Machine = new Machine
@@ -236,7 +236,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
_datdata.Roms.Add(key, temp); _datdata.Roms.Add(key, temp);
} }
@@ -259,10 +259,10 @@ namespace SabreTools
List<string> keys = _datdata.Roms.Keys.ToList(); List<string> keys = _datdata.Roms.Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<Rom> roms = _datdata.Roms[key]; List<Helper.File> roms = _datdata.Roms[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
_datdata.Roms.Add(inkey, temp); _datdata.Roms.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.Roms.Count == 0) if (lastparent != null && _datdata.Roms.Count == 0)
{ {
_datdata.Roms.Add("temp", new List<Rom>()); _datdata.Roms.Add("temp", new List<Helper.File>());
} }
} }
@@ -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)
{ {
Rom rom = ArchiveTools.GetTorrentGZFileInfo(item, _logger); Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
_datdata.Roms.Add(key, temp); _datdata.Roms.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<Rom> extracted = ArchiveTools.GetArchiveFileInfo(item, _logger); List<Helper.File> extracted = ArchiveTools.GetArchiveFileInfo(item, _logger);
foreach (Rom rom in extracted) foreach (Helper.File 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) +
@@ -401,7 +401,7 @@ namespace SabreTools
} }
} }
// Otherwise, just get the info on the file itself // Otherwise, just get the info on the file itself
else if (!Directory.Exists(item) && File.Exists(item)) else if (!Directory.Exists(item) && System.IO.File.Exists(item))
{ {
lastparent = ProcessFile(item, sw, _basePath, "", _datdata, lastparent); lastparent = ProcessFile(item, sw, _basePath, "", _datdata, lastparent);
} }
@@ -440,7 +440,7 @@ namespace SabreTools
} }
} }
// Otherwise, just get the info on the file itself // Otherwise, just get the info on the file itself
else if (!Directory.Exists(item) && File.Exists(item)) else if (!Directory.Exists(item) && System.IO.File.Exists(item))
{ {
lastparent = ProcessFile(item, sw, _basePath, "", _datdata, lastparent); lastparent = ProcessFile(item, sw, _basePath, "", _datdata, lastparent);
} }
@@ -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");
Rom rom = RomTools.GetSingleFileInfo(item, _noMD5, _noSHA1); Helper.File 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, Rom rom, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent) private string ProcessFileHelper(string item, Helper.File rom, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent)
{ {
try try
{ {
@@ -537,7 +537,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
_datdata.Roms.Add(key, temp); _datdata.Roms.Add(key, temp);
} }

View File

@@ -163,7 +163,7 @@ namespace SabreTools
foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories)) foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
{ {
string hash = ""; string hash = "";
using (FileStream fs = File.Open(file, FileMode.Open)) using (FileStream fs = System.IO.File.Open(file, FileMode.Open))
{ {
hash = BitConverter.ToString(sha1.ComputeHash(fs)).Replace("-", ""); hash = BitConverter.ToString(sha1.ComputeHash(fs)).Replace("-", "");
} }
@@ -188,11 +188,11 @@ namespace SabreTools
List<string> keys = datdata.Roms.Keys.ToList(); List<string> keys = datdata.Roms.Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> newroms = datdata.Roms[key]; List<Helper.File> newroms = datdata.Roms[key];
for (int i = 0; i < newroms.Count; i++) for (int i = 0; i < newroms.Count; i++)
{ {
Rom rom = newroms[i]; Helper.File 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)

View File

@@ -39,15 +39,15 @@ namespace SabreTools
public bool Process() public bool Process()
{ {
// Check all of the files for validity and break if one doesn't exist // Check all of the files for validity and break if one doesn't exist
if (_currentAllMerged != "" && !File.Exists(_currentAllMerged)) if (_currentAllMerged != "" && !System.IO.File.Exists(_currentAllMerged))
{ {
return false; return false;
} }
if (_currentMissingMerged != "" && !File.Exists(_currentMissingMerged)) if (_currentMissingMerged != "" && !System.IO.File.Exists(_currentMissingMerged))
{ {
return false; return false;
} }
if (_currentNewMerged != "" && !File.Exists(_currentNewMerged)) if (_currentNewMerged != "" && !System.IO.File.Exists(_currentNewMerged))
{ {
return false; return false;
} }
@@ -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<Rom>> netNew = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> netNew = new Dictionary<string, List<Helper.File>>();
foreach (string key in completeDats.Roms.Keys) foreach (string key in completeDats.Roms.Keys)
{ {
List<Rom> templist = RomTools.Merge(completeDats.Roms[key], _logger); List<Helper.File> templist = RomTools.Merge(completeDats.Roms[key], _logger);
foreach (Rom rom in templist) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
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<Rom>> unneeded = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> unneeded = new Dictionary<string, List<Helper.File>>();
foreach (string key in completeDats.Roms.Keys) foreach (string key in completeDats.Roms.Keys)
{ {
List<Rom> templist = RomTools.Merge(completeDats.Roms[key], _logger); List<Helper.File> templist = RomTools.Merge(completeDats.Roms[key], _logger);
foreach (Rom rom in templist) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
unneeded.Add(key, temp); unneeded.Add(key, temp);
} }
@@ -124,11 +124,11 @@ namespace SabreTools
midMissing.Roms.Add(key, unneeded[key]); midMissing.Roms.Add(key, unneeded[key]);
} }
} }
Dictionary<string, List<Rom>> newMissing = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> newMissing = new Dictionary<string, List<Helper.File>>();
foreach (string key in midMissing.Roms.Keys) foreach (string key in midMissing.Roms.Keys)
{ {
List<Rom> templist = RomTools.Merge(midMissing.Roms[key], _logger); List<Helper.File> templist = RomTools.Merge(midMissing.Roms[key], _logger);
foreach (Rom rom in templist) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
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<Rom>> midHave = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> midHave = new Dictionary<string, List<Helper.File>>();
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 (Rom rom in completeDats.Roms[key]) foreach (Helper.File rom in completeDats.Roms[key])
{ {
if (rom.Metadata.System == _currentNewMerged) if (rom.Metadata.System == _currentNewMerged)
{ {
@@ -185,8 +185,8 @@ namespace SabreTools
} }
else else
{ {
List<Rom> roms = new List<Rom>(); List<Helper.File> roms = new List<Helper.File>();
foreach (Rom rom in completeDats.Roms[key]) foreach (Helper.File rom in completeDats.Roms[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<Rom>> have = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> have = new Dictionary<string, List<Helper.File>>();
foreach (string key in midHave.Keys) foreach (string key in midHave.Keys)
{ {
List<Rom> templist = RomTools.Merge(midHave[key], _logger); List<Helper.File> templist = RomTools.Merge(midHave[key], _logger);
foreach (Rom rom in templist) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> roms = netNew[key]; List<Helper.File> roms = netNew[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> roms = unneeded[key]; List<Helper.File> roms = unneeded[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> roms = newMissing[key]; List<Helper.File> roms = newMissing[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> roms = have[key]; List<Helper.File> roms = have[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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<Rom>> have = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> have = new Dictionary<string, List<Helper.File>>();
foreach (string key in midHave.Roms.Keys) foreach (string key in midHave.Roms.Keys)
{ {
List<Rom> templist = RomTools.Merge(midHave.Roms[key], _logger); List<Helper.File> templist = RomTools.Merge(midHave.Roms[key], _logger);
foreach (Rom rom in templist) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> roms = have[key]; List<Helper.File> roms = have[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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<Rom>> have = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> have = new Dictionary<string, List<Helper.File>>();
foreach (string key in midHave.Roms.Keys) foreach (string key in midHave.Roms.Keys)
{ {
List<Rom> templist = RomTools.Merge(midHave.Roms[key], _logger); List<Helper.File> templist = RomTools.Merge(midHave.Roms[key], _logger);
foreach (Rom rom in templist) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
List<Rom> roms = have[key]; List<Helper.File> roms = have[key];
for (int i = 0; i < roms.Count; i++) for (int i = 0; i < roms.Count; i++)
{ {
Rom rom = roms[i]; Helper.File 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;

View File

@@ -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" : ""),
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
}; };
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();
@@ -436,7 +436,7 @@ namespace SabreTools
// Verify the input files // Verify the input files
foreach (string input in inputs) foreach (string input in inputs)
{ {
if (!File.Exists(input) && !Directory.Exists(input)) if (!System.IO.File.Exists(input) && !Directory.Exists(input))
{ {
_logger.Error(input + " is not a valid file or folder!"); _logger.Error(input + " is not a valid file or folder!");
Console.WriteLine(); Console.WriteLine();
@@ -464,7 +464,7 @@ namespace SabreTools
// Verify the input files // Verify the input files
foreach (string input in inputs) foreach (string input in inputs)
{ {
if (!File.Exists(input) && !Directory.Exists(input)) if (!System.IO.File.Exists(input) && !Directory.Exists(input))
{ {
_logger.Error(input + " is not a valid file or folder!"); _logger.Error(input + " is not a valid file or folder!");
Console.WriteLine(); Console.WriteLine();
@@ -506,7 +506,7 @@ namespace SabreTools
foreach (string input in inputs) foreach (string input in inputs)
{ {
if (File.Exists(input)) if (System.IO.File.Exists(input))
{ {
newinputs.Add(input); newinputs.Add(input);
} }

View File

@@ -80,7 +80,7 @@ namespace SabreTools
foreach (string input in _inputs) foreach (string input in _inputs)
{ {
// If it's a file, run the proper split on the file // If it's a file, run the proper split on the file
if (File.Exists(input)) if (System.IO.File.Exists(input))
{ {
if (_hash) if (_hash)
{ {
@@ -155,7 +155,7 @@ namespace SabreTools
ForcePacking = datdata.ForcePacking, ForcePacking = datdata.ForcePacking,
OutputFormat = outputFormat, OutputFormat = outputFormat,
MergeRoms = datdata.MergeRoms, MergeRoms = datdata.MergeRoms,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
}; };
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,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
}; };
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,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
}; };
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,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
}; };
// Now populate each of the DAT objects in turn // Now populate each of the DAT objects in turn
List<string> keys = datdata.Roms.Keys.ToList(); List<string> keys = datdata.Roms.Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<Rom> roms = datdata.Roms[key]; List<Helper.File> roms = datdata.Roms[key];
foreach (Rom rom in roms) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
nodump.Roms.Add(key, temp); nodump.Roms.Add(key, temp);
} }
@@ -254,7 +254,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
sha1.Roms.Add(key, temp); sha1.Roms.Add(key, temp);
} }
@@ -268,7 +268,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
md5.Roms.Add(key, temp); md5.Roms.Add(key, temp);
} }
@@ -282,7 +282,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
crc.Roms.Add(key, temp); crc.Roms.Add(key, temp);
} }
@@ -340,9 +340,9 @@ namespace SabreTools
OutputFormat outputFormat = DatTools.GetOutputFormat(filename); OutputFormat outputFormat = DatTools.GetOutputFormat(filename);
Dat datdataA = new Dat Dat datdataA = new Dat
{ {
FileName = datdata.FileName + " (" + String.Join(",", _extA) + ")", FileName = datdata.FileName + " (" + string.Join(",", _extA) + ")",
Name = datdata.Name + " (" + String.Join(",", _extA) + ")", Name = datdata.Name + " (" + string.Join(",", _extA) + ")",
Description = datdata.Description + " (" + String.Join(",", _extA) + ")", Description = datdata.Description + " (" + string.Join(",", _extA) + ")",
Category = datdata.Category, Category = datdata.Category,
Version = datdata.Version, Version = datdata.Version,
Date = datdata.Date, Date = datdata.Date,
@@ -351,14 +351,14 @@ namespace SabreTools
Homepage = datdata.Homepage, Homepage = datdata.Homepage,
Url = datdata.Url, Url = datdata.Url,
Comment = datdata.Comment, Comment = datdata.Comment,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
OutputFormat = outputFormat, OutputFormat = outputFormat,
}; };
Dat datdataB = new Dat Dat datdataB = new Dat
{ {
FileName = datdata.FileName + " (" + String.Join(",", _extB) + ")", FileName = datdata.FileName + " (" + string.Join(",", _extB) + ")",
Name = datdata.Name + " (" + String.Join(",", _extB) + ")", Name = datdata.Name + " (" + string.Join(",", _extB) + ")",
Description = datdata.Description + " (" + String.Join(",", _extB) + ")", Description = datdata.Description + " (" + string.Join(",", _extB) + ")",
Category = datdata.Category, Category = datdata.Category,
Version = datdata.Version, Version = datdata.Version,
Date = datdata.Date, Date = datdata.Date,
@@ -367,7 +367,7 @@ namespace SabreTools
Homepage = datdata.Homepage, Homepage = datdata.Homepage,
Url = datdata.Url, Url = datdata.Url,
Comment = datdata.Comment, Comment = datdata.Comment,
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
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.Roms.Keys) foreach (string key in datdata.Roms.Keys)
{ {
foreach (Rom rom in datdata.Roms[key]) foreach (Helper.File rom in datdata.Roms[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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
datdataA.Roms.Add(key, temp); datdataA.Roms.Add(key, temp);
} }
@@ -403,7 +403,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
datdataB.Roms.Add(key, temp); datdataB.Roms.Add(key, temp);
} }
@@ -416,7 +416,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
datdataA.Roms.Add(key, temp); datdataA.Roms.Add(key, temp);
} }
@@ -426,7 +426,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
datdataB.Roms.Add(key, temp); datdataB.Roms.Add(key, temp);
} }

View File

@@ -69,7 +69,7 @@ namespace SabreTools
_cursorLeft = Console.CursorLeft; _cursorLeft = Console.CursorLeft;
_matched = new Dat _matched = new Dat
{ {
Roms = new Dictionary<string, List<Rom>>(), Roms = new Dictionary<string, List<Helper.File>>(),
}; };
} }
@@ -167,7 +167,7 @@ namespace SabreTools
else if (temparg.StartsWith("-dat=") || temparg.StartsWith("--dat=")) else if (temparg.StartsWith("-dat=") || temparg.StartsWith("--dat="))
{ {
string datfile = temparg.Split('=')[1]; string datfile = temparg.Split('=')[1];
if (!File.Exists(datfile)) if (!System.IO.File.Exists(datfile))
{ {
logger.Error("DAT must be a valid file: " + datfile); logger.Error("DAT must be a valid file: " + datfile);
Console.WriteLine(); Console.WriteLine();
@@ -206,7 +206,7 @@ namespace SabreTools
zip = 0; zip = 0;
} }
} }
else if (File.Exists(temparg) || Directory.Exists(temparg)) else if (System.IO.File.Exists(temparg) || Directory.Exists(temparg))
{ {
inputs.Add(temparg); inputs.Add(temparg);
} }
@@ -358,7 +358,7 @@ namespace SabreTools
// Setup the fixdat // Setup the fixdat
_matched = (Dat)_datdata.CloneHeader(); _matched = (Dat)_datdata.CloneHeader();
_matched.Roms = new Dictionary<string, List<Rom>>(); _matched.Roms = new Dictionary<string, List<Helper.File>>();
_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<Rom> roms in _datdata.Roms.Values) foreach (List<Helper.File> roms in _datdata.Roms.Values)
{ {
List<Rom> newroms = RomTools.Merge(roms, _logger); List<Helper.File> newroms = RomTools.Merge(roms, _logger);
foreach (Rom rom in newroms) foreach (Helper.File rom in newroms)
{ {
if (rom.Metadata.SourceID == 99) if (rom.Metadata.SourceID == 99)
{ {
@@ -381,7 +381,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(rom); temp.Add(rom);
_matched.Roms.Add(key, temp); _matched.Roms.Add(key, temp);
} }
@@ -414,7 +414,7 @@ namespace SabreTools
List<string> files = new List<string>(); List<string> files = new List<string>();
foreach (string input in _inputs) foreach (string input in _inputs)
{ {
if (File.Exists(input)) if (System.IO.File.Exists(input))
{ {
_logger.Log("File found: '" + input + "'"); _logger.Log("File found: '" + input + "'");
files.Add(Path.GetFullPath(input)); files.Add(Path.GetFullPath(input));
@@ -492,7 +492,7 @@ namespace SabreTools
// Hash and match the external files // Hash and match the external files
if (shouldExternalScan) if (shouldExternalScan)
{ {
Rom rom = RomTools.GetSingleFileInfo(input); Helper.File 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<Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true); List<Helper.File> 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 (Rom found in foundroms) foreach (Helper.File found in foundroms)
{ {
_logger.Log("Matched name: " + found.Name); _logger.Log("Matched name: " + found.Name);
@@ -515,7 +515,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(found); temp.Add(found);
_matched.Roms.Add(key, temp); _matched.Roms.Add(key, temp);
} }
@@ -532,7 +532,7 @@ namespace SabreTools
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.HashData.SHA1 : found.Name) + "'"); _logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.HashData.SHA1 : found.Name) + "'");
try try
{ {
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name))); System.IO.File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
} }
catch { } catch { }
} }
@@ -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);
Rom drom = RomTools.GetSingleFileInfo(newinput); Helper.File 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<Rom> founddroms = RomTools.GetDuplicates(drom, _datdata, _logger, true); List<Helper.File> 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 (Rom found in founddroms) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(found); temp.Add(found);
_matched.Roms.Add(key, temp); _matched.Roms.Add(key, temp);
} }
@@ -599,7 +599,7 @@ namespace SabreTools
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.HashData.SHA1 : found.Name) + "'"); _logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.HashData.SHA1 : found.Name) + "'");
try try
{ {
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name))); System.IO.File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
} }
catch { } catch { }
} }
@@ -616,7 +616,7 @@ namespace SabreTools
} }
// Then output the headered rom (renamed) // Then output the headered rom (renamed)
Rom newfound = found; Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(newfound); temp.Add(newfound);
_matched.Roms.Add(key, temp); _matched.Roms.Add(key, temp);
} }
@@ -644,7 +644,7 @@ namespace SabreTools
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + newfound.Name + "'"); _logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + newfound.Name + "'");
try try
{ {
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(newfound.Name))); System.IO.File.Copy(input, Path.Combine(gamedir, Path.GetFileName(newfound.Name)));
} }
catch { } catch { }
} }
@@ -665,7 +665,7 @@ namespace SabreTools
// Now remove this temporary file // Now remove this temporary file
try try
{ {
File.Delete(newinput); System.IO.File.Delete(newinput);
} }
catch catch
{ {
@@ -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<Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger); List<Helper.File> 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 (Rom rom in internalRomData) foreach (Helper.File 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<Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true); List<Helper.File> 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 (Rom found in foundroms) foreach (Helper.File 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<Rom> temp = new List<Rom>(); List<Helper.File> temp = new List<Helper.File>();
temp.Add(found); temp.Add(found);
_matched.Roms.Add(key, temp); _matched.Roms.Add(key, temp);
} }
@@ -712,7 +712,7 @@ namespace SabreTools
// Copy file to output directory // Copy file to output directory
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'"); _logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger); string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
if (File.Exists(outfile)) if (System.IO.File.Exists(outfile))
{ {
string gamedir = Path.Combine(_outdir, found.Machine.Name); string gamedir = Path.Combine(_outdir, found.Machine.Name);
if (!Directory.Exists(gamedir)) if (!Directory.Exists(gamedir))
@@ -722,7 +722,7 @@ namespace SabreTools
try try
{ {
File.Move(outfile, Path.Combine(gamedir, Path.GetFileName(found.Name))); System.IO.File.Move(outfile, Path.Combine(gamedir, Path.GetFileName(found.Name)));
} }
catch { } catch { }
} }
@@ -735,7 +735,7 @@ namespace SabreTools
if (Build.MonoEnvironment || _tgz) if (Build.MonoEnvironment || _tgz)
{ {
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger); string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
if (File.Exists(outfile)) if (System.IO.File.Exists(outfile))
{ {
if (_tgz) if (_tgz)
{ {
@@ -748,7 +748,7 @@ namespace SabreTools
try try
{ {
File.Delete(outfile); System.IO.File.Delete(outfile);
} }
catch { } catch { }
} }
@@ -773,7 +773,7 @@ namespace SabreTools
{ {
try try
{ {
File.Delete(input); System.IO.File.Delete(input);
} }
catch (Exception) catch (Exception)
{ {
@@ -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<Rom>> scanned = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> scanned = new Dictionary<string, List<Helper.File>>();
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<Rom> roms = new List<Rom>(); List<Helper.File> roms = new List<Helper.File>();
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 (Rom rom in roms) foreach (Helper.File 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<Rom> templist = new List<Rom>(); List<Helper.File> templist = new List<Helper.File>();
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<Rom>> remove = new Dictionary<string, List<Rom>>(); Dictionary<string, List<Helper.File>> remove = new Dictionary<string, List<Helper.File>>();
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<Rom> romsList = _datdata.Roms[key]; List<Helper.File> romsList = _datdata.Roms[key];
List<Rom> scannedList = scanned[key]; List<Helper.File> scannedList = scanned[key];
foreach (Rom rom in scannedList) foreach (Helper.File rom in scannedList)
{ {
if (!romsList.Contains(rom)) if (!romsList.Contains(rom))
{ {
@@ -902,7 +902,7 @@ namespace SabreTools
} }
else else
{ {
List<Rom> templist = new List<Rom>(); List<Helper.File> templist = new List<Helper.File>();
templist.Add(rom); templist.Add(rom);
remove.Add(key, templist); remove.Add(key, templist);
} }

View File

@@ -152,7 +152,7 @@ namespace SabreTools
zip = 0; zip = 0;
} }
} }
else if (File.Exists(temparg) || Directory.Exists(temparg)) else if (System.IO.File.Exists(temparg) || Directory.Exists(temparg))
{ {
inputs.Add(temparg); inputs.Add(temparg);
} }
@@ -223,7 +223,7 @@ namespace SabreTools
List<string> newinputs = new List<string>(); List<string> newinputs = new List<string>();
foreach (string input in inputs) foreach (string input in inputs)
{ {
if (File.Exists(input)) if (System.IO.File.Exists(input))
{ {
newinputs.Add(Path.GetFullPath(input)); newinputs.Add(Path.GetFullPath(input));
} }
@@ -305,7 +305,7 @@ namespace SabreTools
try try
{ {
_logger.User("Attempting to delete " + input); _logger.User("Attempting to delete " + input);
File.Delete(input); System.IO.File.Delete(input);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -329,7 +329,7 @@ namespace SabreTools
} }
// If we're in romba mode and the size file doesn't exist, create it // If we're in romba mode and the size file doesn't exist, create it
if (_romba && !File.Exists(Path.Combine(_outdir, ".romba_size"))) if (_romba && !System.IO.File.Exists(Path.Combine(_outdir, ".romba_size")))
{ {
// Get the size of all of the files in the output folder // Get the size of all of the files in the output folder
long size = 0; long size = 0;
@@ -340,8 +340,8 @@ namespace SabreTools
} }
// Write out the value to each of the romba depot files // Write out the value to each of the romba depot files
using (StreamWriter tw = new StreamWriter(File.Open(Path.Combine(_outdir, ".romba_size"), FileMode.Create, FileAccess.Write))) using (StreamWriter tw = new StreamWriter(System.IO.File.Open(Path.Combine(_outdir, ".romba_size"), FileMode.Create, FileAccess.Write)))
using (StreamWriter twb = new StreamWriter(File.Open(Path.Combine(_outdir, ".romba_size.backup"), FileMode.Create, FileAccess.Write))) using (StreamWriter twb = new StreamWriter(System.IO.File.Open(Path.Combine(_outdir, ".romba_size.backup"), FileMode.Create, FileAccess.Write)))
{ {
tw.Write(size); tw.Write(size);
twb.Write(size); twb.Write(size);