mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Convert Dat from a struct to an object
This effectively doesn't do much for the time being since there's only one "Dat type" that's being used. Realistically, this is probably the best bet since a given DAT should not be restricted to an output type as much as an ItemType is bound to its data. This also removes the experimental classes that won't be in use for forever. More work still might need to be done but it is unknown at this point.
This commit is contained in:
@@ -18,7 +18,7 @@ namespace SabreTools
|
||||
private string _tempDir;
|
||||
|
||||
// User specified inputs
|
||||
private Dat _datdata;
|
||||
private DatFile _datdata;
|
||||
private bool _noMD5;
|
||||
private bool _noSHA1;
|
||||
private bool _bare;
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools
|
||||
private Logger _logger;
|
||||
|
||||
// Public variables
|
||||
public Dat DatData
|
||||
public DatFile DatData
|
||||
{
|
||||
get { return _datdata; }
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace SabreTools
|
||||
/// <param name="tempDir">Name of the directory to create a temp folder in (blank is current directory)</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logger object for console and file output</param>
|
||||
public DATFromDir(string basePath, Dat datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles,
|
||||
public DATFromDir(string basePath, DatFile datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles,
|
||||
bool enableGzip, bool addBlanks, bool addDate, string tempDir, int maxDegreeOfParallelism, Logger logger)
|
||||
{
|
||||
_basePath = Path.GetFullPath(basePath);
|
||||
|
||||
4347
SabreTools.Helper/Objects/DatObjects/DatFile.cs
Normal file
4347
SabreTools.Helper/Objects/DatObjects/DatFile.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -166,7 +166,7 @@ namespace SabreTools
|
||||
string intname = systemname + " (" + sourcename + ")";
|
||||
string datname = systemname + " (" + sourcename + " " + version + ")";
|
||||
|
||||
Dat datdata = new Dat
|
||||
DatFile datdata = new DatFile
|
||||
{
|
||||
Name = intname,
|
||||
Description = datname,
|
||||
@@ -179,7 +179,7 @@ namespace SabreTools
|
||||
Files = dict,
|
||||
};
|
||||
|
||||
return DatTools.WriteDatfile(datdata, _outDir, _logger);
|
||||
return DatFile.WriteDatfile(datdata, _outDir, _logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// Create the output DatData object
|
||||
Dat datdata = new Dat
|
||||
DatFile datdata = new DatFile
|
||||
{
|
||||
FileName = description,
|
||||
Name = name,
|
||||
@@ -173,7 +173,7 @@ namespace SabreTools
|
||||
{
|
||||
Int32.TryParse(sourcemap[hash], out tempSrcId);
|
||||
}
|
||||
DatTools.Parse(file, 0, tempSrcId, ref datdata, _logger);
|
||||
DatFile.Parse(file, 0, tempSrcId, ref datdata, _logger);
|
||||
}
|
||||
|
||||
// If the dictionary is empty for any reason, tell the user and exit
|
||||
@@ -238,7 +238,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// Then write out the file
|
||||
DatTools.WriteDatfile(datdata, _outroot, _logger, _norename);
|
||||
DatFile.WriteDatfile(datdata, _outroot, _logger, _norename);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -366,8 +366,8 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// Get all roms that are found in the DAT to see what needs to be added
|
||||
Dat datdata = new Dat();
|
||||
DatTools.Parse(_filepath, sysid, srcid, ref datdata, _logger);
|
||||
DatFile datdata = new DatFile();
|
||||
DatFile.Parse(_filepath, sysid, srcid, ref datdata, _logger);
|
||||
|
||||
// Sort inputted roms into games
|
||||
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SabreTools.Helper
|
||||
public class SimpleSort
|
||||
{
|
||||
// Private instance variables
|
||||
private Dat _datdata;
|
||||
private DatFile _datdata;
|
||||
private List<string> _inputs;
|
||||
private string _outDir;
|
||||
private string _tempDir;
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.Helper
|
||||
// Other private variables
|
||||
private int _cursorTop;
|
||||
private int _cursorLeft;
|
||||
private Dat _matched;
|
||||
private DatFile _matched;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new SimpleSort object
|
||||
@@ -51,7 +51,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="zip">Integer representing the archive handling level for Zip</param>
|
||||
/// <param name="updateDat">True if the updated DAT should be output, false otherwise</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
public SimpleSort(Dat datdata, List<string> inputs, string outDir, string tempDir,
|
||||
public SimpleSort(DatFile datdata, List<string> inputs, string outDir, string tempDir,
|
||||
bool quickScan, bool toFolder, bool verify, bool delete, bool? torrentX, bool romba, int sevenzip,
|
||||
int gz, int rar, int zip, bool updateDat, Logger logger)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace SabreTools.Helper
|
||||
|
||||
_cursorTop = Console.CursorTop;
|
||||
_cursorLeft = Console.CursorLeft;
|
||||
_matched = new Dat
|
||||
_matched = new DatFile
|
||||
{
|
||||
Files = new Dictionary<string, List<DatItem>>(),
|
||||
};
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Setup the fixdat
|
||||
_matched = (Dat)_datdata.CloneHeader();
|
||||
_matched = (DatFile)_datdata.CloneHeader();
|
||||
_matched.Files = new Dictionary<string, List<DatItem>>();
|
||||
_matched.FileName = "fixDat_" + _matched.FileName;
|
||||
_matched.Name = "fixDat_" + _matched.Name;
|
||||
@@ -179,7 +179,7 @@ namespace SabreTools.Helper
|
||||
// Now output the fixdat to the main folder
|
||||
if (found)
|
||||
{
|
||||
DatTools.WriteDatfile(_matched, "", _logger, stats: true);
|
||||
DatFile.WriteDatfile(_matched, "", _logger, stats: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -273,7 +273,7 @@ namespace SabreTools.Helper
|
||||
_datdata.Name = "fixDat_" + _datdata.Name;
|
||||
_datdata.Description = "fixDat_" + _datdata.Description;
|
||||
_datdata.OutputFormat = OutputFormat.Xml;
|
||||
DatTools.WriteDatfile(_datdata, "", _logger);
|
||||
DatFile.WriteDatfile(_datdata, "", _logger);
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -341,7 +341,7 @@ namespace SabreTools.Helper
|
||||
|
||||
// Now loop through all of the files and check them, DFD style
|
||||
_logger.User("Getting source file information...");
|
||||
Dat matchdat = new Dat
|
||||
DatFile matchdat = new DatFile
|
||||
{
|
||||
Files = new Dictionary<string, List<DatItem>>(),
|
||||
};
|
||||
@@ -429,7 +429,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Then bucket the keys by game for better output
|
||||
SortedDictionary<string, List<DatItem>> keysByGame = DatTools.BucketByGame(toFromMap.Keys.ToList(), false, true, _logger);
|
||||
SortedDictionary<string, List<DatItem>> keysByGame = DatFile.BucketByGame(toFromMap.Keys.ToList(), false, true, _logger);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -456,7 +456,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="file">Name of the file to attempt to add</param>
|
||||
/// <param name="matchdat">Reference to the Dat to add to</param>
|
||||
/// <returns>True if the file could be added, false otherwise</returns>
|
||||
public bool RebuildToOutputAlternateParseRomHelper(string file, ref Dat matchdat)
|
||||
public bool RebuildToOutputAlternateParseRomHelper(string file, ref DatFile matchdat)
|
||||
{
|
||||
Rom rom = FileTools.GetSingleFileInfo(file);
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace SabreTools.Helper
|
||||
{
|
||||
_logger.Log("Beginning stat collection for '" + filename + "'");
|
||||
List<String> games = new List<String>();
|
||||
Dat datdata = new Dat();
|
||||
DatTools.Parse(filename, 0, 0, ref datdata, _logger);
|
||||
SortedDictionary<string, List<DatItem>> newroms = DatTools.BucketByGame(datdata.Files, false, true, _logger, false);
|
||||
DatFile datdata = new DatFile();
|
||||
DatFile.Parse(filename, 0, 0, ref datdata, _logger);
|
||||
SortedDictionary<string, List<DatItem>> newroms = DatFile.BucketByGame(datdata.Files, false, true, _logger, false);
|
||||
|
||||
// Output single DAT stats (if asked)
|
||||
if (_single)
|
||||
@@ -76,7 +76,7 @@ namespace SabreTools.Helper
|
||||
|
||||
// Output total DAT stats
|
||||
if (!_single) { _logger.User(""); }
|
||||
Dat totaldata = new Dat
|
||||
DatFile totaldata = new DatFile
|
||||
{
|
||||
TotalSize = totalSize,
|
||||
RomCount = totalRom,
|
||||
@@ -102,7 +102,7 @@ Please check the log folder if the stats scrolled offscreen");
|
||||
/// <param name="logger">Logger object for file and console writing</param>
|
||||
/// <param name="recalculate">True if numbers should be recalculated for the DAT, false otherwise (default)</param>
|
||||
/// <param name="game">Number of games to use, -1 means recalculate games (default)</param>
|
||||
public static void OutputStats(Dat datdata, Logger logger, bool recalculate = false, long game = -1)
|
||||
public static void OutputStats(DatFile datdata, Logger logger, bool recalculate = false, long game = -1)
|
||||
{
|
||||
if (recalculate)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ Please check the log folder if the stats scrolled offscreen");
|
||||
}
|
||||
}
|
||||
|
||||
SortedDictionary<string, List<DatItem>> newroms = DatTools.BucketByGame(datdata.Files, false, true, logger, false);
|
||||
SortedDictionary<string, List<DatItem>> newroms = DatFile.BucketByGame(datdata.Files, false, true, logger, false);
|
||||
if (datdata.TotalSize < 0)
|
||||
{
|
||||
datdata.TotalSize = Int64.MaxValue + datdata.TotalSize;
|
||||
|
||||
Reference in New Issue
Block a user