mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFiles/, DatItem, ArchiveTools, FileTools] Notes and tweaks
This commit is contained in:
@@ -231,7 +231,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteStartGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
|
||||
@@ -706,7 +706,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -774,7 +774,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteStartGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -812,7 +812,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game end using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteEndGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -833,14 +833,14 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="datFile">DatFile to write out from</param>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -4211,8 +4211,8 @@ namespace SabreTools.Library.DatFiles
|
||||
if (shouldExternalProcess)
|
||||
{
|
||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||
Rom rom = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), header: headerToCheckAgainst);
|
||||
usedExternally = RebuildIndividualFile(rom, file, outDir, tempSubDir, date, inverse, outputFormat,
|
||||
Rom fileinfo = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), header: headerToCheckAgainst);
|
||||
usedExternally = RebuildIndividualFile(fileinfo, file, outDir, tempSubDir, date, inverse, outputFormat,
|
||||
romba, updateDat, null /* isZip */, headerToCheckAgainst);
|
||||
}
|
||||
|
||||
@@ -4242,8 +4242,8 @@ namespace SabreTools.Library.DatFiles
|
||||
if (entries == null && File.Exists(file))
|
||||
{
|
||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||
Rom rom = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes));
|
||||
usedExternally = RebuildIndividualFile(rom, file, outDir, tempSubDir, date, inverse, outputFormat,
|
||||
Rom fileinfo = FileTools.GetFileInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes));
|
||||
usedExternally = RebuildIndividualFile(fileinfo, file, outDir, tempSubDir, date, inverse, outputFormat,
|
||||
romba, updateDat, null /* isZip */, headerToCheckAgainst);
|
||||
}
|
||||
// Otherwise, loop through the entries and try to match
|
||||
@@ -4270,7 +4270,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <summary>
|
||||
/// Find duplicates and rebuild individual files to output
|
||||
/// </summary>
|
||||
/// <param name="rom">Information for the current file to rebuild from</param>
|
||||
/// <param name="datItem">Information for the current file to rebuild from</param>
|
||||
/// <param name="file">Name of the file to process</param>
|
||||
/// <param name="outDir">Output directory to use to build to</param>
|
||||
/// <param name="tempDir">Temporary directory for archive extraction</param>
|
||||
@@ -4282,20 +4282,23 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="isZip">True if the input file is an archive, false if the file is TGZ, null otherwise</param>
|
||||
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
/// <returns>True if the file was able to be rebuilt, false otherwise</returns>
|
||||
private bool RebuildIndividualFile(Rom rom, string file, string outDir, string tempDir, bool date,
|
||||
private bool RebuildIndividualFile(DatItem datItem, string file, string outDir, string tempDir, bool date,
|
||||
bool inverse, OutputFormat outputFormat, bool romba, bool updateDat, bool? isZip, string headerToCheckAgainst)
|
||||
{
|
||||
// TODO: Don't assume this is a Rom once Disk parsing is created
|
||||
Rom rom = (Rom)datItem;
|
||||
|
||||
// Set the output value
|
||||
bool rebuilt = false;
|
||||
|
||||
// Find if the file has duplicates in the DAT
|
||||
bool hasDuplicates = rom.HasDuplicates(this);
|
||||
bool hasDuplicates = datItem.HasDuplicates(this);
|
||||
|
||||
// If it has duplicates and we're not filtering, rebuild it
|
||||
if (hasDuplicates && !inverse)
|
||||
{
|
||||
// Get the list of duplicates to rebuild to
|
||||
List<DatItem> dupes = rom.GetDuplicates(this, remove: updateDat);
|
||||
List<DatItem> dupes = datItem.GetDuplicates(this, remove: updateDat);
|
||||
|
||||
// If we don't have any duplicates, continue
|
||||
if (dupes.Count == 0)
|
||||
@@ -4340,7 +4343,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (isZip != null)
|
||||
{
|
||||
string realName = null;
|
||||
(fileStream, realName) = ArchiveTools.ExtractStream(file, rom.Name);
|
||||
(fileStream, realName) = ArchiveTools.ExtractStream(file, datItem.Name);
|
||||
}
|
||||
// Otherwise, just open the filestream
|
||||
else
|
||||
@@ -4357,7 +4360,7 @@ namespace SabreTools.Library.DatFiles
|
||||
// Seek to the beginning of the stream
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
Globals.Logger.User("Matches found for '{0}', rebuilding accordingly...", Style.GetFileName(rom.Name));
|
||||
Globals.Logger.User("Matches found for '{0}', rebuilding accordingly...", Style.GetFileName(datItem.Name));
|
||||
rebuilt = true;
|
||||
|
||||
// Now loop through the list and rebuild accordingly
|
||||
@@ -4436,7 +4439,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (isZip != null)
|
||||
{
|
||||
string realName = null;
|
||||
(fileStream, realName) = ArchiveTools.ExtractStream(file, rom.Name);
|
||||
(fileStream, realName) = ArchiveTools.ExtractStream(file, datItem.Name);
|
||||
}
|
||||
// Otherwise, just open the filestream
|
||||
else
|
||||
@@ -4462,7 +4465,7 @@ namespace SabreTools.Library.DatFiles
|
||||
item.MachineDescription = machinename;
|
||||
}
|
||||
|
||||
Globals.Logger.User("No matches found for '{0}', rebuilding accordingly from inverse flag...", Style.GetFileName(rom.Name));
|
||||
Globals.Logger.User("No matches found for '{0}', rebuilding accordingly from inverse flag...", Style.GetFileName(datItem.Name));
|
||||
|
||||
// Now rebuild to the output file
|
||||
switch (outputFormat)
|
||||
@@ -4537,7 +4540,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (isZip != null)
|
||||
{
|
||||
string realName = null;
|
||||
(fileStream, realName) = ArchiveTools.ExtractStream(file, rom.Name);
|
||||
(fileStream, realName) = ArchiveTools.ExtractStream(file, datItem.Name);
|
||||
}
|
||||
// Otherwise, just open the filestream
|
||||
else
|
||||
@@ -4579,15 +4582,15 @@ namespace SabreTools.Library.DatFiles
|
||||
return rebuilt;
|
||||
}
|
||||
|
||||
Globals.Logger.User("Headerless matches found for '{0}', rebuilding accordingly...", Style.GetFileName(rom.Name));
|
||||
Globals.Logger.User("Headerless matches found for '{0}', rebuilding accordingly...", Style.GetFileName(datItem.Name));
|
||||
rebuilt = true;
|
||||
|
||||
// Now loop through the list and rebuild accordingly
|
||||
foreach (Rom item in dupes)
|
||||
{
|
||||
// Create a headered item to use as well
|
||||
rom.CopyMachineInformation(item);
|
||||
rom.Name += "_" + rom.CRC;
|
||||
datItem.CopyMachineInformation(item);
|
||||
datItem.Name += "_" + rom.CRC;
|
||||
|
||||
// If either copy succeeds, then we want to set rebuilt to true
|
||||
bool eitherSuccess = false;
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -202,7 +202,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteStartGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -232,7 +232,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game end using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteEndGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -253,13 +253,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData( sw, hash, rom, ignoreblanks);
|
||||
WriteDatItem( sw, hash, rom, ignoreblanks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,14 +182,14 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="hash">Hash that should be written out</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, Hash hash, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, Hash hash, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -342,7 +342,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteStartGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -393,13 +393,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -1250,7 +1250,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -1330,7 +1330,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteStartGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -1400,13 +1400,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, lastgame, ignoreblanks);
|
||||
WriteDatItem(sw, rom, lastgame, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -141,14 +141,14 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="lastgame">The name of the last game to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, string lastgame, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, string lastgame, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -249,13 +249,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -322,13 +322,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, depth, ignoreblanks);
|
||||
WriteDatItem(sw, rom, depth, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
splitpath = newsplit;
|
||||
@@ -221,7 +221,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="newsplit">Split path representing the parent game (SabreDAT only)</param>
|
||||
/// <param name="lastgame">The name of the last game to be output</param>
|
||||
/// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
||||
@@ -319,14 +319,14 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, int depth, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, int depth, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, delim, rom, ignoreblanks);
|
||||
WriteDatItem(sw, delim, rom, ignoreblanks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,14 +466,14 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="delim">Delimiter for parsing individual lines</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, char delim, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, char delim, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, rom, ignoreblanks);
|
||||
WriteDatItem(sw, rom, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
lastgame = rom.MachineName;
|
||||
@@ -203,7 +203,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteStartGame(StreamWriter sw, DatItem rom)
|
||||
{
|
||||
@@ -273,13 +273,13 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// Write out DatItem using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="rom">DatItem object to be output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteRomData(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
private bool WriteDatItem(StreamWriter sw, DatItem rom, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks
|
||||
|
||||
@@ -821,7 +821,7 @@ namespace SabreTools.Library.Items
|
||||
/// Merge an arbitrary set of ROMs based on the supplied information
|
||||
/// </summary>
|
||||
/// <param name="infiles">List of File objects representing the roms to be merged</param>
|
||||
/// <returns>A List of RomData objects representing the merged roms</returns>
|
||||
/// <returns>A List of DatItem objects representing the merged roms</returns>
|
||||
public static List<DatItem> Merge(List<DatItem> infiles)
|
||||
{
|
||||
// Check for null or blank roms first
|
||||
@@ -948,7 +948,7 @@ namespace SabreTools.Library.Items
|
||||
/// Resolve name duplicates in an arbitrary set of ROMs based on the supplied information
|
||||
/// </summary>
|
||||
/// <param name="infiles">List of File objects representing the roms to be merged</param>
|
||||
/// <returns>A List of RomData objects representing the renamed roms</returns>
|
||||
/// <returns>A List of DatItem objects representing the renamed roms</returns>
|
||||
public static List<DatItem> ResolveNames(List<DatItem> infiles)
|
||||
{
|
||||
// Create the output list
|
||||
|
||||
@@ -426,11 +426,11 @@ namespace SabreTools.Library.Tools
|
||||
#region Information
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of RomData objects from the header values in an archive
|
||||
/// Generate a list of DatItem objects from the header values in an archive
|
||||
/// </summary>
|
||||
/// <param name="input">Input file to get data from</param>
|
||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||
/// <returns>List of RomData objects representing the found data</returns>
|
||||
/// <returns>List of DatItem objects representing the found data</returns>
|
||||
public static List<Rom> GetArchiveFileInfo(string input, bool date = false)
|
||||
{
|
||||
return GetExtendedArchiveFileInfo(input, Hash.SecureHashes, date: date);
|
||||
@@ -581,12 +581,12 @@ namespace SabreTools.Library.Tools
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a list of RomData objects from the header values in an archive
|
||||
/// Generate a list of DatItem objects from the header values in an archive
|
||||
/// </summary>
|
||||
/// <param name="input">Input file to get data from</param>
|
||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||
/// <returns>List of RomData objects representing the found data</returns>
|
||||
/// <returns>List of DatItem objects representing the found data</returns>
|
||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||
public static List<Rom> GetExtendedArchiveFileInfo(string input, Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
||||
{
|
||||
@@ -831,7 +831,7 @@ namespace SabreTools.Library.Tools
|
||||
/// Retrieve file information for a single torrent GZ file
|
||||
/// </summary>
|
||||
/// <param name="input">Filename to get information from</param>
|
||||
/// <returns>Populated RomData object if success, empty one on error</returns>
|
||||
/// <returns>Populated DatItem object if success, empty one on error</returns>
|
||||
public static Rom GetTorrentGZFileInfo(string input)
|
||||
{
|
||||
// Check for the file existing first
|
||||
@@ -1369,7 +1369,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <param name="overwrite">True if we should overwrite the file if it exists, false otherwise</param>
|
||||
/// <returns>True if the file was written properly, false otherwise</returns>
|
||||
@@ -1451,7 +1451,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTAR(string inputFile, string outDir, Rom rom, bool date = false)
|
||||
@@ -1465,7 +1465,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputStream">Input stream to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTAR(Stream inputStream, string outDir, Rom rom, bool date = false)
|
||||
@@ -1767,7 +1767,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrent7Zip(string inputFile, string outDir, Rom rom, bool date = false)
|
||||
@@ -1781,7 +1781,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputStream">Input stream to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrent7Zip(Stream inputStream, string outDir, Rom rom, bool date = false)
|
||||
@@ -2286,7 +2286,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentLRZ(string inputFile, string outDir, Rom rom, bool date = false)
|
||||
@@ -2300,7 +2300,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputStream">Input stream to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentLRZ(Stream inputStream, string outDir, Rom rom, bool date = false)
|
||||
@@ -2313,7 +2313,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentRAR(string inputFile, string outDir, Rom rom, bool date = false)
|
||||
@@ -2327,7 +2327,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputStream">Input stream to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentRAR(Stream inputStream, string outDir, Rom rom, bool date = false)
|
||||
@@ -2340,7 +2340,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentXZ(string inputFile, string outDir, Rom rom, bool date = false)
|
||||
@@ -2354,7 +2354,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputStream">Input stream to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentXZ(Stream inputStream, string outDir, Rom rom, bool date = false)
|
||||
@@ -2747,7 +2747,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputFile">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentZip(string inputFile, string outDir, Rom rom, bool date = false)
|
||||
@@ -2761,7 +2761,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="inputStream">Input filename to be moved</param>
|
||||
/// <param name="outDir">Output directory to build to</param>
|
||||
/// <param name="rom">RomData representing the new information</param>
|
||||
/// <param name="rom">DatItem representing the new information</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
|
||||
/// <returns>True if the archive was written properly, false otherwise</returns>
|
||||
public static bool WriteTorrentZip(Stream inputStream, string outDir, Rom rom, bool date = false)
|
||||
|
||||
@@ -212,7 +212,10 @@ namespace SabreTools.Library.Tools
|
||||
/// <param name="offset">Set a >0 number for getting hash for part of the file, 0 otherwise (default)</param>
|
||||
/// <param name="date">True if the file Date should be included, false otherwise (default)</param>
|
||||
/// <param name="header">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
/// <returns>Populated RomData object if success, empty one on error</returns>
|
||||
/// <returns>Populated DatItem object if success, empty one on error</returns>
|
||||
/// <remarks>
|
||||
/// TODO: Add CHD parsing logic here to get internal hash data
|
||||
/// </remarks>
|
||||
public static Rom GetFileInfo(string input, Hash omitFromScan = 0x0,
|
||||
long offset = 0, bool date = false, string header = null)
|
||||
{
|
||||
@@ -729,7 +732,7 @@ namespace SabreTools.Library.Tools
|
||||
/// <param name="omitFromScan">Hash flag saying what hashes should not be calculated (defaults to none)</param>
|
||||
/// <param name="offset">Set a >0 number for getting hash for part of the file, 0 otherwise (default)</param>
|
||||
/// <param name="keepReadOpen">True if the underlying read stream should be kept open, false otherwise</param>
|
||||
/// <returns>Populated RomData object if success, empty one on error</returns>
|
||||
/// <returns>Populated DatItem object if success, empty one on error</returns>
|
||||
public static Rom GetStreamInfo(Stream input, long size, Hash omitFromScan = 0x0,
|
||||
long offset = 0, bool keepReadOpen = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user