[DatFiles/, Utilities] Create DatFIle factory

This commit is contained in:
Matt Nadareski
2017-11-17 14:58:54 -08:00
parent b578dd1274
commit 7d1a578eb9
14 changed files with 158 additions and 182 deletions

View File

@@ -45,7 +45,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,

View File

@@ -46,7 +46,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -630,7 +630,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -1795,7 +1795,7 @@ namespace SabreTools.Library.DatFiles
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace, splitpath: true);
// Once we're done, try writing out
intDat.WriteToFile(interOutDir);
intDat.Write(interOutDir);
// Due to possible memory requirements, we force a garbage collection
GC.Collect();
@@ -1873,7 +1873,7 @@ namespace SabreTools.Library.DatFiles
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace, splitpath: true);
// Once we're done, try writing out
intDat.WriteToFile(interOutDir);
intDat.Write(interOutDir);
// Due to possible memory requirements, we force a garbage collection
GC.Collect();
@@ -1962,7 +1962,7 @@ namespace SabreTools.Library.DatFiles
string path = Utilities.GetOutputPath(outDir, inputs[j], inplace, splitpath: true);
// Try to output the file
outDats[j].WriteToFile(path);
outDats[j].Write(path);
});
watch.Stop();
@@ -2104,13 +2104,13 @@ namespace SabreTools.Library.DatFiles
// Output the difflist (a-b)+(b-a) diff
if ((diff & UpdateMode.DiffNoDupesOnly) != 0)
{
outerDiffData.WriteToFile(outDir);
outerDiffData.Write(outDir);
}
// Output the (ab) diff
if ((diff & UpdateMode.DiffDupesOnly) != 0)
{
dupeData.WriteToFile(outDir);
dupeData.Write(outDir);
}
// Output the individual (a-b) DATs
@@ -2121,7 +2121,7 @@ namespace SabreTools.Library.DatFiles
string path = Utilities.GetOutputPath(outDir, inputs[j], false /* inplace */, splitpath: true);
// Try to output the file
outDats[j].WriteToFile(path);
outDats[j].Write(path);
});
}
@@ -2165,7 +2165,7 @@ namespace SabreTools.Library.DatFiles
}
// Try to output the file
WriteToFile(outDir);
Write(outDir);
}
/// <summary>
@@ -2206,7 +2206,7 @@ namespace SabreTools.Library.DatFiles
// Try to output the file, overwriting only if it's not in the current directory
// TODO: Figure out if overwriting should always happen of if there should be a user flag
innerDatdata.WriteToFile(realOutDir, overwrite: (realOutDir != Environment.CurrentDirectory));
innerDatdata.Write(realOutDir, overwrite: (realOutDir != Environment.CurrentDirectory));
}
}
@@ -3056,62 +3056,7 @@ namespace SabreTools.Library.DatFiles
// Now parse the correct type of DAT
try
{
switch (Utilities.GetDatFormat(filename))
{
case DatFormat.AttractMode:
new AttractMode(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.ClrMamePro:
new ClrMamePro(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.CSV:
new SeparatedValue(this, ',').ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.DOSCenter:
new DosCenter(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.Listroms:
new Listroms(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.Logiqx:
new Logiqx(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.OfflineList:
new OfflineList(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.RedumpMD5:
new Hashfile(this).ParseFile(filename, sysid, srcid, Hash.MD5, clean, remUnicode);
break;
case DatFormat.RedumpSFV:
new Hashfile(this).ParseFile(filename, sysid, srcid, Hash.CRC, clean, remUnicode);
break;
case DatFormat.RedumpSHA1:
new Hashfile(this).ParseFile(filename, sysid, srcid, Hash.SHA1, clean, remUnicode);
break;
case DatFormat.RedumpSHA256:
new Hashfile(this).ParseFile(filename, sysid, srcid, Hash.SHA256, clean, remUnicode);
break;
case DatFormat.RedumpSHA384:
new Hashfile(this).ParseFile(filename, sysid, srcid, Hash.SHA384, clean, remUnicode);
break;
case DatFormat.RedumpSHA512:
new Hashfile(this).ParseFile(filename, sysid, srcid, Hash.SHA512, clean, remUnicode);
break;
case DatFormat.RomCenter:
new RomCenter(this).ParseFile(filename, sysid, srcid, clean, remUnicode);
break;
case DatFormat.SabreDat:
new SabreDat(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.SoftwareList:
new SoftwareList(this).ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
case DatFormat.TSV:
new SeparatedValue(this, '\t').ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
break;
default:
return;
}
Utilities.CreateDatFileFromTypeAndBase(Utilities.GetDatFormat(filename), this)?.ParseFile(filename, sysid, srcid, keep, clean, remUnicode);
}
catch (Exception ex)
{
@@ -3327,6 +3272,29 @@ namespace SabreTools.Library.DatFiles
return await Task.Run(() => ParseAddHelper(item, clean, remUnicode));
}
/// <summary>
/// Parse DatFile and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="sysid">System ID for the DAT</param>
/// <param name="srcid">Source ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public virtual void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
int srcid,
// Miscellaneous
bool keep,
bool clean,
bool remUnicode)
{
throw new NotImplementedException();
}
#endregion
#region Populate DAT from Directory
@@ -3909,7 +3877,7 @@ namespace SabreTools.Library.DatFiles
Name = "fixDAT_" + Name;
Description = "fixDAT_" + Description;
RemoveMarkedItems();
WriteToFile(outDir);
Write(outDir);
}
return success;
@@ -4040,7 +4008,7 @@ namespace SabreTools.Library.DatFiles
Name = "fixDAT_" + Name;
Description = "fixDAT_" + Description;
RemoveMarkedItems();
WriteToFile(outDir);
Write(outDir);
}
return success;
@@ -4569,7 +4537,7 @@ namespace SabreTools.Library.DatFiles
FileName = "fixDAT_" + FileName;
Name = "fixDAT_" + Name;
Description = "fixDAT_" + Description;
WriteToFile();
Write();
return success;
}
@@ -4645,7 +4613,7 @@ namespace SabreTools.Library.DatFiles
}
// Now output the fixdat to the main folder
success &= matched.WriteToFile(stats: true);
success &= matched.Write(stats: true);
return success;
}
@@ -4801,8 +4769,8 @@ namespace SabreTools.Library.DatFiles
});
// Then write out both files
bool success = datdataA.WriteToFile(outDir);
success &= datdataB.WriteToFile(outDir);
bool success = datdataA.Write(outDir);
success &= datdataB.Write(outDir);
return success;
}
@@ -5049,13 +5017,13 @@ namespace SabreTools.Library.DatFiles
// Now, output all of the files to the output directory
Globals.Logger.User("DAT information created, outputting new files");
bool success = true;
success &= nodump.WriteToFile(outDir);
success &= sha512.WriteToFile(outDir);
success &= sha384.WriteToFile(outDir);
success &= sha256.WriteToFile(outDir);
success &= sha1.WriteToFile(outDir);
success &= md5.WriteToFile(outDir);
success &= crc.WriteToFile(outDir);
success &= nodump.Write(outDir);
success &= sha512.Write(outDir);
success &= sha384.Write(outDir);
success &= sha256.Write(outDir);
success &= sha1.Write(outDir);
success &= md5.Write(outDir);
success &= crc.Write(outDir);
return success;
}
@@ -5156,7 +5124,7 @@ namespace SabreTools.Library.DatFiles
datFile.Type = null;
// Write out the temporary DAT to the proper directory
datFile.WriteToFile(outDir);
datFile.Write(outDir);
}
/// <summary>
@@ -5260,9 +5228,9 @@ namespace SabreTools.Library.DatFiles
// Now, output all of the files to the output directory
Globals.Logger.User("DAT information created, outputting new files");
bool success = true;
success &= romdat.WriteToFile(outDir);
success &= diskdat.WriteToFile(outDir);
success &= sampledat.WriteToFile(outDir);
success &= romdat.Write(outDir);
success &= diskdat.Write(outDir);
success &= sampledat.Write(outDir);
return success;
}
@@ -5360,7 +5328,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="overwrite">True if files should be overwritten (default), false if they should be renamed instead</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outDir = null, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true)
public bool Write(string outDir = null, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true)
{
// If there's nothing there, abort
if (Count == 0)
@@ -5458,63 +5426,7 @@ namespace SabreTools.Library.DatFiles
string outfile = outfiles[datFormat];
try
{
switch (datFormat)
{
case DatFormat.AttractMode:
new AttractMode(this).WriteToFile(outfile);
break;
case DatFormat.ClrMamePro:
new ClrMamePro(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.CSV:
new SeparatedValue(this, ',').WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.DOSCenter:
new DosCenter(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.Listroms:
new Listroms(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.Logiqx:
new Logiqx(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.MissFile:
new Missfile(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.OfflineList:
new OfflineList(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.RedumpMD5:
new Hashfile(this).WriteToFile(outfile, Hash.MD5, ignoreblanks);
break;
case DatFormat.RedumpSFV:
new Hashfile(this).WriteToFile(outfile, Hash.CRC, ignoreblanks);
break;
case DatFormat.RedumpSHA1:
new Hashfile(this).WriteToFile(outfile, Hash.SHA1, ignoreblanks);
break;
case DatFormat.RedumpSHA256:
new Hashfile(this).WriteToFile(outfile, Hash.SHA256, ignoreblanks);
break;
case DatFormat.RedumpSHA384:
new Hashfile(this).WriteToFile(outfile, Hash.SHA384, ignoreblanks);
break;
case DatFormat.RedumpSHA512:
new Hashfile(this).WriteToFile(outfile, Hash.SHA512, ignoreblanks);
break;
case DatFormat.RomCenter:
new RomCenter(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.SabreDat:
new SabreDat(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.SoftwareList:
new SoftwareList(this).WriteToFile(outfile, ignoreblanks);
break;
case DatFormat.TSV:
new SeparatedValue(this, '\t').WriteToFile(outfile, ignoreblanks);
break;
}
Utilities.CreateDatFileFromTypeAndBase(datFormat, this)?.WriteToFile(outfile, ignoreblanks);
}
catch (Exception ex)
{
@@ -5532,6 +5444,17 @@ namespace SabreTools.Library.DatFiles
return true;
}
/// <summary>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public virtual bool WriteToFile(string outfile, bool ignoreblanks = false)
{
throw new NotImplementedException();
}
/// <summary>
/// Generate a proper outfile name based on a DAT and output directory
/// </summary>

View File

@@ -45,7 +45,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -67,7 +67,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -24,16 +24,21 @@ namespace SabreTools.Library.DatFiles
/// </summary>
internal class Hashfile : DatFile
{
// Private instance variables specific to Hashfile DATs
Hash _hash;
/// <summary>
/// Constructor designed for casting a base DatFile
/// </summary>
/// <param name="datFile">Parent DatFile to copy from</param>
public Hashfile(DatFile datFile)
/// <param name="hash">Type of hash that is associated with this DAT</param>
public Hashfile(DatFile datFile, Hash hash)
{
this._datHeader = datFile._datHeader;
this._items = datFile._items;
this._sortedBy = datFile._sortedBy;
this._datStats = datFile._datStats;
_hash = hash;
}
/// <summary>
@@ -42,19 +47,17 @@ namespace SabreTools.Library.DatFiles
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="sysid">System ID for the DAT</param>
/// <param name="srcid">Source ID for the DAT</param>
/// <param name="hashtype">Hash type that should be assumed</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
int srcid,
// Specific to hash files
Hash hashtype,
// Miscellaneous
bool keep,
bool clean,
bool remUnicode)
{
@@ -72,7 +75,7 @@ namespace SabreTools.Library.DatFiles
string hash = "";
// If we have CRC, then it's an SFV file and the name is first are
if ((hashtype & Hash.CRC) != 0)
if ((_hash & Hash.CRC) != 0)
{
name = split[0].Replace("*", String.Empty);
hash = split[1];
@@ -88,12 +91,12 @@ namespace SabreTools.Library.DatFiles
{
Name = name,
Size = -1,
CRC = ((hashtype & Hash.CRC) != 0 ? hash : null),
MD5 = ((hashtype & Hash.MD5) != 0 ? hash : null),
SHA1 = ((hashtype & Hash.SHA1) != 0 ? hash : null),
SHA256 = ((hashtype & Hash.SHA256) != 0 ? hash : null),
SHA384 = ((hashtype & Hash.SHA384) != 0 ? hash : null),
SHA512 = ((hashtype & Hash.SHA512) != 0 ? hash : null),
CRC = ((_hash & Hash.CRC) != 0 ? hash : null),
MD5 = ((_hash & Hash.MD5) != 0 ? hash : null),
SHA1 = ((_hash & Hash.SHA1) != 0 ? hash : null),
SHA256 = ((_hash & Hash.SHA256) != 0 ? hash : null),
SHA384 = ((_hash & Hash.SHA384) != 0 ? hash : null),
SHA512 = ((_hash & Hash.SHA512) != 0 ? hash : null),
ItemStatus = ItemStatus.None,
MachineName = Path.GetFileNameWithoutExtension(filename),
@@ -113,10 +116,9 @@ namespace SabreTools.Library.DatFiles
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="hash">Hash that should be written out</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, Hash hash, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{
@@ -163,7 +165,7 @@ namespace SabreTools.Library.DatFiles
}
// Now, output the rom data
WriteDatItem( sw, hash, rom, ignoreblanks);
WriteDatItem(sw, rom, ignoreblanks);
}
}
@@ -184,11 +186,10 @@ namespace SabreTools.Library.DatFiles
/// 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">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 WriteDatItem(StreamWriter sw, Hash hash, 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
@@ -201,7 +202,7 @@ namespace SabreTools.Library.DatFiles
try
{
string state = "";
switch (hash)
switch (_hash)
{
case Hash.MD5:
if (rom.Type == ItemType.Rom)

View File

@@ -55,7 +55,7 @@ namespace SabreTools.Library.DatFiles
/// 6331.sound-u8 32 BAD CRC(1d298cb0) SHA1(bb0bb62365402543e3154b9a77be9c75010e6abc) BAD_DUMP
/// 16v8h-blue.u24 279 NO GOOD DUMP KNOWN
/// </remarks>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -246,7 +246,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -50,7 +50,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <remarks>
/// </remarks>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -1176,7 +1176,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -36,7 +36,7 @@ namespace SabreTools.Library.DatFiles
}
/// <summary>
/// Parse a Missfileand return all found games and roms within
/// Parse a Missfile and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="sysid">System ID for the DAT</param>
@@ -44,9 +44,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <remarks>
/// </remarks>
public void Parse(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -67,7 +65,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -47,7 +47,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <remarks>
/// </remarks>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -68,7 +68,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -43,15 +43,17 @@ namespace SabreTools.Library.DatFiles
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="sysid">System ID for the DAT</param>
/// <param name="srcid">Source ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
int srcid,
// Miscellaneous
bool keep,
bool clean,
bool remUnicode)
{
@@ -202,7 +204,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -48,7 +48,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <remarks>
/// </remarks>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -69,7 +69,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -49,7 +49,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -374,7 +374,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -48,7 +48,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <remarks>
/// </remarks>
public void ParseFile(
public override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
@@ -69,7 +69,7 @@ namespace SabreTools.Library.DatFiles
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public bool WriteToFile(string outfile, bool ignoreblanks = false)
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
{
try
{

View File

@@ -10,6 +10,7 @@ using System.Xml;
using System.Xml.Schema;
using SabreTools.Library.Data;
using SabreTools.Library.DatFiles;
using SabreTools.Library.External;
using SabreTools.Library.FileTypes;
using SabreTools.Library.DatItems;
@@ -536,6 +537,57 @@ namespace SabreTools.Library.Tools
}
}
/// <summary>
/// Create a specific type of DatFile to be used based on a format and a base DAT
/// </summary>
/// <param name="datFormat">Format of the DAT to be created</param>
/// <param name="baseDat">DatFile containing the information to use in specific operations</param>
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
public static DatFile CreateDatFileFromTypeAndBase(DatFormat datFormat, DatFile baseDat)
{
switch (datFormat)
{
case DatFormat.AttractMode:
return new AttractMode(baseDat);
case DatFormat.ClrMamePro:
return new ClrMamePro(baseDat);
case DatFormat.CSV:
return new SeparatedValue(baseDat, ',');
case DatFormat.DOSCenter:
return new DosCenter(baseDat);
case DatFormat.Listroms:
return new Listroms(baseDat);
case DatFormat.Logiqx:
return new Logiqx(baseDat);
case DatFormat.MissFile:
return new Missfile(baseDat);
case DatFormat.OfflineList:
return new OfflineList(baseDat);
case DatFormat.RedumpMD5:
return new Hashfile(baseDat, Hash.MD5);
case DatFormat.RedumpSFV:
return new Hashfile(baseDat, Hash.CRC);
case DatFormat.RedumpSHA1:
return new Hashfile(baseDat, Hash.SHA1);
case DatFormat.RedumpSHA256:
return new Hashfile(baseDat, Hash.SHA256);
case DatFormat.RedumpSHA384:
return new Hashfile(baseDat, Hash.SHA384);
case DatFormat.RedumpSHA512:
return new Hashfile(baseDat, Hash.SHA512);
case DatFormat.RomCenter:
return new RomCenter(baseDat);
case DatFormat.SabreDat:
return new SabreDat(baseDat);
case DatFormat.SoftwareList:
return new SoftwareList(baseDat);
case DatFormat.TSV:
return new SeparatedValue(baseDat, '\t');
}
return null;
}
#endregion
#region File Information