[DatFile] Remove all references to Files as an independent variable

This commit is contained in:
Matt Nadareski
2016-11-08 15:50:27 -08:00
parent 82a31ed470
commit 3aa0ad3f62
12 changed files with 163 additions and 234 deletions

View File

@@ -423,9 +423,9 @@ namespace SabreTools
{ {
sldr.Read(); sldr.Read();
string hash = sldr.GetString(0); string hash = sldr.GetString(0);
if (datroot.Files.ContainsKey(hash)) if (datroot.ContainsKey(hash))
{ {
datroot.Files[hash] = null; datroot[hash] = null;
databaseDats.Add(hash); databaseDats.Add(hash);
} }
else if (!databaseDats.Contains(hash)) else if (!databaseDats.Contains(hash))
@@ -443,7 +443,7 @@ namespace SabreTools
// Loop through the Dictionary and add all data // Loop through the Dictionary and add all data
_logger.User("Adding new DAT information"); _logger.User("Adding new DAT information");
start = DateTime.Now; start = DateTime.Now;
foreach (string key in datroot.Keys()) foreach (string key in datroot.Keys)
{ {
foreach (Rom value in datroot[key]) foreach (Rom value in datroot[key])
{ {
@@ -490,9 +490,9 @@ namespace SabreTools
string md5sha1query = "INSERT OR IGNORE INTO md5sha1 (md5, sha1) VALUES"; string md5sha1query = "INSERT OR IGNORE INTO md5sha1 (md5, sha1) VALUES";
// Loop through the parsed entries // Loop through the parsed entries
foreach (string romkey in tempdat.Files.Keys) foreach (string romkey in tempdat.Keys)
{ {
foreach (DatItem datItem in tempdat.Files[romkey]) foreach (DatItem datItem in tempdat[romkey])
{ {
_logger.Verbose("Checking and adding file '" + datItem.Name); _logger.Verbose("Checking and adding file '" + datItem.Name);
@@ -628,10 +628,10 @@ namespace SabreTools
// Once we have both, check for any new files // Once we have both, check for any new files
List<string> dupehashes = new List<string>(); List<string> dupehashes = new List<string>();
List<string> keys = depot.Files.Keys.ToList(); List<string> keys = depot.Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = depot.Files[key]; List<DatItem> roms = depot[key];
foreach (Rom rom in roms) foreach (Rom rom in roms)
{ {
if (hashes.Contains(rom.SHA1)) if (hashes.Contains(rom.SHA1))

View File

@@ -52,7 +52,6 @@ namespace SabreTools
// Create an empty Dat for files that need to be rebuilt // Create an empty Dat for files that need to be rebuilt
DatFile need = new DatFile(); DatFile need = new DatFile();
need.Files = new SortedDictionary<string, List<DatItem>>();
// Open the database connection // Open the database connection
SqliteConnection dbc = new SqliteConnection(_connectionString); SqliteConnection dbc = new SqliteConnection(_connectionString);
@@ -65,9 +64,9 @@ namespace SabreTools
string crcsha1query = "INSERT OR IGNORE INTO crcsha1 (crc, sha1) VALUES"; string crcsha1query = "INSERT OR IGNORE INTO crcsha1 (crc, sha1) VALUES";
string md5sha1query = "INSERT OR IGNORE INTO md5sha1 (md5, sha1) VALUES"; string md5sha1query = "INSERT OR IGNORE INTO md5sha1 (md5, sha1) VALUES";
foreach (string key in df.Files.Keys) foreach (string key in df.Keys)
{ {
List<DatItem> datItems = df.Files[key]; List<DatItem> datItems = df[key];
foreach (Rom rom in datItems) foreach (Rom rom in datItems)
{ {
// If we care about if the file exists, check the databse first // If we care about if the file exists, check the databse first
@@ -242,7 +241,6 @@ namespace SabreTools
Name = Path.GetFileName(inputs[0]) + " Dir2Dat", Name = Path.GetFileName(inputs[0]) + " Dir2Dat",
Description = Path.GetFileName(inputs[0]) + " Dir2Dat", Description = Path.GetFileName(inputs[0]) + " Dir2Dat",
DatFormat = DatFormat.Logiqx, DatFormat = DatFormat.Logiqx,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
Logger logger = new Logger(); Logger logger = new Logger();

View File

@@ -159,21 +159,6 @@ namespace SabreTools.Helper.Dats
get { return _mergeRoms; } get { return _mergeRoms; }
set { _mergeRoms = value; } set { _mergeRoms = value; }
} }
protected SortedDictionary<string, List<DatItem>> Files
{
get
{
if (_files == null)
{
_files = new SortedDictionary<string, List<DatItem>>();
}
return _files;
}
set
{
_files = value;
}
}
public SortedBy SortedBy public SortedBy SortedBy
{ {
get { return _sortedBy; } get { return _sortedBy; }
@@ -431,6 +416,14 @@ namespace SabreTools.Helper.Dats
} }
} }
/// <summary>
/// Delete the file dictionary
/// </summary>
public void Delete()
{
_files = null;
}
/// <summary> /// <summary>
/// Get the keys from the file dictionary /// Get the keys from the file dictionary
/// </summary> /// </summary>
@@ -474,13 +467,30 @@ namespace SabreTools.Helper.Dats
} }
} }
/// <summary>
/// Reset the file dictionary
/// </summary>
public void Reset()
{
_files = new SortedDictionary<string, List<DatItem>>();
}
/// <summary>
/// Set a new file dictionary from an existing one
/// </summary>
/// <param name="newdict"></param>
public void Set(SortedDictionary<string, List<DatItem>> newdict)
{
_files = newdict;
}
#endregion #endregion
#region Cloning Methods [MODULAR DONE] #region Cloning Methods [MODULAR DONE]
public object Clone() public object Clone()
{ {
return new DatFile DatFile df = new DatFile
{ {
FileName = _fileName, FileName = _fileName,
Name = _name, Name = _name,
@@ -502,7 +512,6 @@ namespace SabreTools.Helper.Dats
ExcludeOf = _excludeOf, ExcludeOf = _excludeOf,
DatFormat = _datFormat, DatFormat = _datFormat,
MergeRoms = _mergeRoms, MergeRoms = _mergeRoms,
Files = _files,
SortedBy = _sortedBy, SortedBy = _sortedBy,
UseGame = _useGame, UseGame = _useGame,
Prefix = _prefix, Prefix = _prefix,
@@ -522,6 +531,9 @@ namespace SabreTools.Helper.Dats
BaddumpCount = _baddumpCount, BaddumpCount = _baddumpCount,
NodumpCount = _nodumpCount, NodumpCount = _nodumpCount,
}; };
df.Set(_files);
return df;
} }
public object CloneHeader() public object CloneHeader()
@@ -548,7 +560,6 @@ namespace SabreTools.Helper.Dats
ExcludeOf = _excludeOf, ExcludeOf = _excludeOf,
DatFormat = _datFormat, DatFormat = _datFormat,
MergeRoms = _mergeRoms, MergeRoms = _mergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
SortedBy = SortedBy.Default, SortedBy = SortedBy.Default,
UseGame = _useGame, UseGame = _useGame,
Prefix = _prefix, Prefix = _prefix,

View File

@@ -33,19 +33,13 @@ namespace SabreTools.Helper.Dats
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>(); SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0; long count = 0;
// If we have a null dict or an empty one, output a new dictionary
if (Files == null || Files.Count == 0)
{
Files = sortable;
}
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by CRC"); logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by CRC");
// Process each all of the roms // Process each all of the roms
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = Files[key]; List<DatItem> roms = this[key];
// If we're merging the roms, do so // If we're merging the roms, do so
if (mergeroms) if (mergeroms)
@@ -83,7 +77,7 @@ namespace SabreTools.Helper.Dats
} }
// Now assign the dictionary back // Now assign the dictionary back
Files = sortable; _files = sortable;
} }
/// <summary> /// <summary>
@@ -108,19 +102,13 @@ namespace SabreTools.Helper.Dats
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>(); SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0; long count = 0;
// If we have a null dict or an empty one, output a new dictionary
if (Files == null || Files.Count == 0)
{
Files = sortable;
}
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by game"); logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by game");
// Process each all of the roms // Process each all of the roms
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = Files[key]; List<DatItem> roms = this[key];
// If we're merging the roms, do so // If we're merging the roms, do so
if (mergeroms) if (mergeroms)
@@ -170,7 +158,7 @@ namespace SabreTools.Helper.Dats
} }
// Now assign the dictionary back // Now assign the dictionary back
Files = sortable; _files = sortable;
} }
/// <summary> /// <summary>
@@ -193,19 +181,13 @@ namespace SabreTools.Helper.Dats
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>(); SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0; long count = 0;
// If we have a null dict or an empty one, output a new dictionary
if (Files == null || Files.Count == 0)
{
Files = sortable;
}
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by MD5"); logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by MD5");
// Process each all of the roms // Process each all of the roms
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = Files[key]; List<DatItem> roms = this[key];
// If we're merging the roms, do so // If we're merging the roms, do so
if (mergeroms) if (mergeroms)
@@ -247,7 +229,7 @@ namespace SabreTools.Helper.Dats
} }
// Now assign the dictionary back // Now assign the dictionary back
Files = sortable; _files = sortable;
} }
/// <summary> /// <summary>
@@ -270,19 +252,13 @@ namespace SabreTools.Helper.Dats
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>(); SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0; long count = 0;
// If we have a null dict or an empty one, output a new dictionary
if (Files == null || Files.Count == 0)
{
Files = sortable;
}
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-1"); logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-1");
// Process each all of the roms // Process each all of the roms
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = Files[key]; List<DatItem> roms = this[key];
// If we're merging the roms, do so // If we're merging the roms, do so
if (mergeroms) if (mergeroms)
@@ -324,7 +300,7 @@ namespace SabreTools.Helper.Dats
} }
// Now assign the dictionary back // Now assign the dictionary back
Files = sortable; _files = sortable;
} }
/// <summary> /// <summary>
@@ -347,19 +323,13 @@ namespace SabreTools.Helper.Dats
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>(); SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0; long count = 0;
// If we have a null dict or an empty one, output a new dictionary
if (Files == null || Files.Count == 0)
{
Files = sortable;
}
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by size"); logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by size");
// Process each all of the roms // Process each all of the roms
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = Files[key]; List<DatItem> roms = this[key];
// If we're merging the roms, do so // If we're merging the roms, do so
if (mergeroms) if (mergeroms)
@@ -397,7 +367,7 @@ namespace SabreTools.Helper.Dats
} }
// Now assign the dictionary back // Now assign the dictionary back
Files = sortable; _files = sortable;
} }
#endregion #endregion

View File

@@ -110,7 +110,6 @@ namespace SabreTools.Helper.Dats
datHeaders[i] = new DatFile datHeaders[i] = new DatFile
{ {
DatFormat = (DatFormat != 0 ? DatFormat : 0), DatFormat = (DatFormat != 0 ? DatFormat : 0),
Files = new SortedDictionary<string, List<DatItem>>(),
MergeRoms = MergeRoms, MergeRoms = MergeRoms,
}; };
@@ -120,16 +119,15 @@ namespace SabreTools.Helper.Dats
logger.User("Processing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); logger.User("Processing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
logger.User("Populating internal DAT"); logger.User("Populating internal DAT");
Files = new SortedDictionary<string, List<DatItem>>();
for (int i = 0; i < inputs.Count; i++) for (int i = 0; i < inputs.Count; i++)
{ {
List<string> keys = datHeaders[i].Files.Keys.ToList(); List<string> keys = datHeaders[i].Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
AddRange(key, datHeaders[i][key]); AddRange(key, datHeaders[i][key]);
datHeaders[i].Remove(key); datHeaders[i].Remove(key);
} }
datHeaders[i].Files = null; datHeaders[i].Delete();
} }
/// END /// END
@@ -163,7 +161,7 @@ namespace SabreTools.Helper.Dats
outerDiffData.FileName += post; outerDiffData.FileName += post;
outerDiffData.Name += post; outerDiffData.Name += post;
outerDiffData.Description += post; outerDiffData.Description += post;
outerDiffData.Files = new SortedDictionary<string, List<DatItem>>(); outerDiffData.Reset();
} }
// Have External dupes // Have External dupes
@@ -174,7 +172,7 @@ namespace SabreTools.Helper.Dats
dupeData.FileName += post; dupeData.FileName += post;
dupeData.Name += post; dupeData.Name += post;
dupeData.Description += post; dupeData.Description += post;
dupeData.Files = new SortedDictionary<string, List<DatItem>>(); dupeData.Reset();
} }
// Create a list of DatData objects representing individual output files // Create a list of DatData objects representing individual output files
@@ -192,7 +190,7 @@ namespace SabreTools.Helper.Dats
diffData.FileName += innerpost; diffData.FileName += innerpost;
diffData.Name += innerpost; diffData.Name += innerpost;
diffData.Description += innerpost; diffData.Description += innerpost;
diffData.Files = new SortedDictionary<string, List<DatItem>>(); diffData.Reset();
outDatsArray[j] = diffData; outDatsArray[j] = diffData;
}); });
@@ -203,10 +201,10 @@ namespace SabreTools.Helper.Dats
// Now, loop through the dictionary and populate the correct DATs // Now, loop through the dictionary and populate the correct DATs
start = DateTime.Now; start = DateTime.Now;
logger.User("Populating all output DATs"); logger.User("Populating all output DATs");
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = DatItem.Merge(Files[key], logger); List<DatItem> roms = DatItem.Merge(this[key], logger);
if (roms != null && roms.Count > 0) if (roms != null && roms.Count > 0)
{ {
@@ -278,7 +276,7 @@ namespace SabreTools.Helper.Dats
: (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length))); : (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length)));
// If we have more than 0 roms, output // If we have more than 0 roms, output
if (outDats[j].Files.Count > 0) if (outDats[j].Count > 0)
{ {
outDats[j].WriteToFile(path, logger); outDats[j].WriteToFile(path, logger);
} }
@@ -326,7 +324,7 @@ namespace SabreTools.Helper.Dats
diffData.Name += post; diffData.Name += post;
diffData.Description += post; diffData.Description += post;
} }
diffData.Files = new SortedDictionary<string, List<DatItem>>(); diffData.Reset();
outDatsArray[j] = diffData; outDatsArray[j] = diffData;
}); });
@@ -337,11 +335,11 @@ namespace SabreTools.Helper.Dats
// Now, loop through the dictionary and populate the correct DATs // Now, loop through the dictionary and populate the correct DATs
start = DateTime.Now; start = DateTime.Now;
logger.User("Populating all output DATs"); logger.User("Populating all output DATs");
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = DatItem.Merge(Files[key], logger); List<DatItem> roms = DatItem.Merge(this[key], logger);
if (roms != null && roms.Count > 0) if (roms != null && roms.Count > 0)
{ {
@@ -380,7 +378,7 @@ namespace SabreTools.Helper.Dats
} }
// If we have more than 0 roms, output // If we have more than 0 roms, output
if (outDats[j].Files.Count > 0) if (outDats[j].Count > 0)
{ {
outDats[j].WriteToFile(path, logger); outDats[j].WriteToFile(path, logger);
} }
@@ -400,11 +398,11 @@ namespace SabreTools.Helper.Dats
// If we're in SuperDAT mode, prefix all games with their respective DATs // If we're in SuperDAT mode, prefix all games with their respective DATs
if (Type == "SuperDAT") if (Type == "SuperDAT")
{ {
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> newroms = new List<DatItem>(); List<DatItem> newroms = new List<DatItem>();
foreach (DatItem rom in Files[key]) foreach (DatItem rom in this[key])
{ {
DatItem newrom = rom; DatItem newrom = rom;
string filename = inputs[newrom.SystemID].Split('¬')[0]; string filename = inputs[newrom.SystemID].Split('¬')[0];
@@ -417,12 +415,12 @@ namespace SabreTools.Helper.Dats
+ newrom.Machine.Name; + newrom.Machine.Name;
newroms.Add(newrom); newroms.Add(newrom);
} }
Files[key] = newroms; this[key] = newroms;
} }
} }
// Output a DAT only if there are roms // Output a DAT only if there are roms
if (Files.Count != 0) if (Count != 0)
{ {
WriteToFile(outDir, logger); WriteToFile(outDir, logger);
} }
@@ -468,7 +466,7 @@ namespace SabreTools.Helper.Dats
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0)); keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
// If we have roms, output them // If we have roms, output them
if (innerDatdata.Files.Count != 0) if (innerDatdata.Count != 0)
{ {
innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(inputFileName) : outDir), logger, overwrite: (outDir != "")); innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(inputFileName) : outDir), logger, overwrite: (outDir != ""));
} }
@@ -483,13 +481,13 @@ namespace SabreTools.Helper.Dats
{ {
logger.User("Processing \"" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + "\""); logger.User("Processing \"" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + "\"");
DatFile innerDatdata = (DatFile)Clone(); DatFile innerDatdata = (DatFile)Clone();
innerDatdata.Files = null; innerDatdata.Delete();
innerDatdata.Parse(file, 0, 0, filter, innerDatdata.Parse(file, 0, 0, filter,
trim, single, root, logger, true, clean, softlist, trim, single, root, logger, true, clean, softlist,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0)); keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
// If we have roms, output them // If we have roms, output them
if (innerDatdata.Files != null && innerDatdata.Files.Count != 0) if (innerDatdata.Count > 0)
{ {
innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(file) : outDir + Path.GetDirectoryName(file).Remove(0, inputFileName.Length - 1)), logger, overwrite: (outDir != "")); innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(file) : outDir + Path.GetDirectoryName(file).Remove(0, inputFileName.Length - 1)), logger, overwrite: (outDir != ""));
} }

View File

@@ -62,12 +62,6 @@ namespace SabreTools.Helper.Dats
Description = Name + (bare ? "" : " (" + Date + ")"); Description = Name + (bare ? "" : " (" + Date + ")");
} }
// Make sure the dictionary is defined
if (Files == null || Files.Keys.Count == 0)
{
Files = new SortedDictionary<string, List<DatItem>>();
}
// Process the input // Process the input
if (Directory.Exists(basePath)) if (Directory.Exists(basePath))
{ {
@@ -159,7 +153,7 @@ namespace SabreTools.Helper.Dats
} }
logger.Verbose("Adding blank empty folder: " + gamename); logger.Verbose("Adding blank empty folder: " + gamename);
Files["null"].Add(new Rom(romname, gamename)); this["null"].Add(new Rom(romname, gamename));
} }
}); });
} }

View File

@@ -92,12 +92,6 @@ namespace SabreTools.Helper.Dats
// If the output type isn't set already, get the internal output type // If the output type isn't set already, get the internal output type
DatFormat = (DatFormat == 0 ? FileTools.GetDatFormat(filename, logger) : DatFormat); DatFormat = (DatFormat == 0 ? FileTools.GetDatFormat(filename, logger) : DatFormat);
// Make sure there's a dictionary to read to
if (Files == null)
{
Files = new SortedDictionary<string, List<DatItem>>();
}
// Now parse the correct type of DAT // Now parse the correct type of DAT
switch (FileTools.GetDatFormat(filename, logger)) switch (FileTools.GetDatFormat(filename, logger))
{ {
@@ -1582,14 +1576,14 @@ namespace SabreTools.Helper.Dats
// If the rom is continue or ignore, add the size to the previous rom // If the rom is continue or ignore, add the size to the previous rom
if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore") if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore")
{ {
int index = Files[key].Count() - 1; int index = this[key].Count() - 1;
DatItem lastrom = Files[key][index]; DatItem lastrom = this[key][index];
if (lastrom.Type == ItemType.Rom) if (lastrom.Type == ItemType.Rom)
{ {
((Rom)lastrom).Size += size; ((Rom)lastrom).Size += size;
} }
Files[key].RemoveAt(index); this[key].RemoveAt(index);
Files[key].Add(lastrom); this[key].Add(lastrom);
subreader.Read(); subreader.Read();
continue; continue;
} }
@@ -1763,14 +1757,14 @@ namespace SabreTools.Helper.Dats
// If the rom is continue or ignore, add the size to the previous rom // If the rom is continue or ignore, add the size to the previous rom
if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore") if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore")
{ {
int index = Files[key].Count() - 1; int index = this[key].Count() - 1;
DatItem lastrom = Files[key][index]; DatItem lastrom = this[key][index];
if (lastrom.Type == ItemType.Rom) if (lastrom.Type == ItemType.Rom)
{ {
((Rom)lastrom).Size += size; ((Rom)lastrom).Size += size;
} }
Files[key].RemoveAt(index); this[key].RemoveAt(index);
Files[key].Add(lastrom); this[key].Add(lastrom);
continue; continue;
} }
@@ -2320,8 +2314,6 @@ namespace SabreTools.Helper.Dats
} }
} }
lock (Files)
{
// Get the key and add statistical data // Get the key and add statistical data
switch (item.Type) switch (item.Type)
{ {
@@ -2363,7 +2355,6 @@ namespace SabreTools.Helper.Dats
Add(key, item); Add(key, item);
} }
} }
}
#endregion #endregion
} }

View File

@@ -45,7 +45,7 @@ namespace SabreTools.Helper.Dats
#region Perform setup #region Perform setup
// If the DAT is not populated and inverse is not set, inform the user and quit // If the DAT is not populated and inverse is not set, inform the user and quit
if ((Files == null || Files.Count == 0) && !inverse) if (Count == 0 && !inverse)
{ {
logger.User("No entries were found to rebuild, exiting..."); logger.User("No entries were found to rebuild, exiting...");
return false; return false;
@@ -149,24 +149,16 @@ namespace SabreTools.Helper.Dats
{ {
Rom rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan, header: headerToCheckAgainst); Rom rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan, header: headerToCheckAgainst);
rom.Name = Path.GetFullPath(file); rom.Name = Path.GetFullPath(file);
lock (Files)
{
current.Add(rom.Size + "-" + rom.CRC, rom); current.Add(rom.Size + "-" + rom.CRC, rom);
}
// If we had a header, we want the full file information too // If we had a header, we want the full file information too
if (headerToCheckAgainst != null) if (headerToCheckAgainst != null)
{ {
rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan); rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan);
rom.Name = Path.GetFullPath(file); rom.Name = Path.GetFullPath(file);
lock (Files)
{
current.Add(rom.Size + "-" + rom.CRC, rom); current.Add(rom.Size + "-" + rom.CRC, rom);
} }
} }
}
// If we're supposed to scan the file internally // If we're supposed to scan the file internally
if (shouldInternalProcess) if (shouldInternalProcess)
@@ -180,13 +172,9 @@ namespace SabreTools.Helper.Dats
{ {
Rom newrom = rom; Rom newrom = rom;
newrom.Machine = new Machine(Path.GetFullPath(file), ""); newrom.Machine = new Machine(Path.GetFullPath(file), "");
lock (Files)
{
current.Add(rom.Size + "-" + rom.CRC, newrom); current.Add(rom.Size + "-" + rom.CRC, newrom);
} }
} }
}
// Otherwise, attempt to extract the files to the temporary directory // Otherwise, attempt to extract the files to the temporary directory
else else
{ {
@@ -203,23 +191,15 @@ namespace SabreTools.Helper.Dats
{ {
Rom rom = FileTools.GetFileInfo(entry, logger, noMD5: quickScan, noSHA1: quickScan, header: headerToCheckAgainst); Rom rom = FileTools.GetFileInfo(entry, logger, noMD5: quickScan, noSHA1: quickScan, header: headerToCheckAgainst);
rom.Machine = new Machine(Path.GetFullPath(file), ""); rom.Machine = new Machine(Path.GetFullPath(file), "");
lock (Files)
{
current.Add(rom.Size + "-" + rom.CRC, rom); current.Add(rom.Size + "-" + rom.CRC, rom);
}
// If we had a header, we want the full file information too // If we had a header, we want the full file information too
if (headerToCheckAgainst != null) if (headerToCheckAgainst != null)
{ {
rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan); rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan);
rom.Machine = new Machine(Path.GetFullPath(file), ""); rom.Machine = new Machine(Path.GetFullPath(file), "");
lock (Files)
{
current.Add(rom.Size + "-" + rom.CRC, rom); current.Add(rom.Size + "-" + rom.CRC, rom);
} }
}
}); });
} }
// Otherwise, just get the info on the file itself // Otherwise, just get the info on the file itself
@@ -227,14 +207,10 @@ namespace SabreTools.Helper.Dats
{ {
Rom rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan, header: headerToCheckAgainst); Rom rom = FileTools.GetFileInfo(file, logger, noMD5: quickScan, noSHA1: quickScan, header: headerToCheckAgainst);
rom.Name = Path.GetFullPath(file); rom.Name = Path.GetFullPath(file);
lock (Files)
{
current.Add(rom.Size + "-" + rom.CRC, rom); current.Add(rom.Size + "-" + rom.CRC, rom);
} }
} }
} }
}
// Now delete the temp directory // Now delete the temp directory
try try
@@ -263,7 +239,7 @@ namespace SabreTools.Helper.Dats
current.BucketByCRC(false, logger, output: false); current.BucketByCRC(false, logger, output: false);
// Now loop over and find all files that need to be rebuilt // Now loop over and find all files that need to be rebuilt
List<string> keys = current.Files.Keys.ToList(); List<string> keys = current.Keys.ToList();
Parallel.ForEach(keys, Parallel.ForEach(keys,
new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }, new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism },
key => key =>
@@ -272,7 +248,7 @@ namespace SabreTools.Helper.Dats
if (inverse) if (inverse)
{ {
// Check for duplicates // Check for duplicates
List<DatItem> datItems = current.Files[key]; List<DatItem> datItems = current[key];
foreach (Rom rom in datItems) foreach (Rom rom in datItems)
{ {
// If the rom has duplicates, we skip it // If the rom has duplicates, we skip it
@@ -312,13 +288,13 @@ namespace SabreTools.Helper.Dats
else else
{ {
// If the input DAT doesn't have the key, then nothing from the current DAT are there // If the input DAT doesn't have the key, then nothing from the current DAT are there
if (!Files.ContainsKey(key)) if (!ContainsKey(key))
{ {
return; return;
} }
// Otherwise, we try to find duplicates // Otherwise, we try to find duplicates
List<DatItem> datItems = current.Files[key]; List<DatItem> datItems = current[key];
foreach (Rom rom in datItems) foreach (Rom rom in datItems)
{ {
List<DatItem> found = rom.GetDuplicates(this, logger, false); List<DatItem> found = rom.GetDuplicates(this, logger, false);
@@ -536,7 +512,7 @@ namespace SabreTools.Helper.Dats
// Setup the fixdat // Setup the fixdat
DatFile matched = (DatFile)CloneHeader(); DatFile matched = (DatFile)CloneHeader();
matched.Files = new SortedDictionary<string, List<DatItem>>(); matched.Reset();
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;
@@ -544,8 +520,9 @@ namespace SabreTools.Helper.Dats
// 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<DatItem> roms in Files.Values) foreach (string key in Keys)
{ {
List<DatItem> roms = this[key];
List<DatItem> newroms = DatItem.Merge(roms, logger); List<DatItem> newroms = DatItem.Merge(roms, logger);
foreach (Rom rom in newroms) foreach (Rom rom in newroms)
{ {

View File

@@ -59,7 +59,6 @@ namespace SabreTools.Helper.Dats
Homepage = this.Homepage, Homepage = this.Homepage,
Url = this.Url, Url = this.Url,
Comment = this.Comment, Comment = this.Comment,
Files = new SortedDictionary<string, List<DatItem>>(),
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
}; };
DatFile datdataB = new DatFile DatFile datdataB = new DatFile
@@ -75,20 +74,19 @@ namespace SabreTools.Helper.Dats
Homepage = this.Homepage, Homepage = this.Homepage,
Url = this.Url, Url = this.Url,
Comment = this.Comment, Comment = this.Comment,
Files = new SortedDictionary<string, List<DatItem>>(),
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
}; };
// If roms is empty, return false // If roms is empty, return false
if (this.Files.Count == 0) if (Count == 0)
{ {
return false; return false;
} }
// Now separate the roms accordingly // Now separate the roms accordingly
foreach (string key in this.Files.Keys) foreach (string key in Keys)
{ {
foreach (DatItem rom in this.Files[key]) foreach (DatItem rom in this[key])
{ {
if (newExtA.Contains(Path.GetExtension(rom.Name.ToUpperInvariant()))) if (newExtA.Contains(Path.GetExtension(rom.Name.ToUpperInvariant())))
{ {
@@ -157,7 +155,6 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
DatFile sha1 = new DatFile DatFile sha1 = new DatFile
{ {
@@ -179,7 +176,6 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
DatFile md5 = new DatFile DatFile md5 = new DatFile
{ {
@@ -201,7 +197,6 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
DatFile crc = new DatFile DatFile crc = new DatFile
{ {
@@ -223,7 +218,6 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
DatFile other = new DatFile DatFile other = new DatFile
@@ -246,14 +240,13 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
// Now populate each of the DAT objects in turn // Now populate each of the DAT objects in turn
List<string> keys = this.Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = this.Files[key]; List<DatItem> roms = this[key];
foreach (DatItem rom in roms) foreach (DatItem rom in roms)
{ {
// If the file is not a Rom or Disk, continue // If the file is not a Rom or Disk, continue
@@ -306,19 +299,19 @@ namespace SabreTools.Helper.Dats
// Now, output all of the files to the output directory // Now, output all of the files to the output directory
logger.User("DAT information created, outputting new files"); logger.User("DAT information created, outputting new files");
bool success = true; bool success = true;
if (nodump.Files.Count > 0) if (nodump.Count > 0)
{ {
success &= nodump.WriteToFile(outDir, logger); success &= nodump.WriteToFile(outDir, logger);
} }
if (sha1.Files.Count > 0) if (sha1.Count > 0)
{ {
success &= sha1.WriteToFile(outDir, logger); success &= sha1.WriteToFile(outDir, logger);
} }
if (md5.Files.Count > 0) if (md5.Count > 0)
{ {
success &= md5.WriteToFile(outDir, logger); success &= md5.WriteToFile(outDir, logger);
} }
if (crc.Files.Count > 0) if (crc.Count > 0)
{ {
success &= crc.WriteToFile(outDir, logger); success &= crc.WriteToFile(outDir, logger);
} }
@@ -348,7 +341,7 @@ namespace SabreTools.Helper.Dats
tempDat.Name = null; tempDat.Name = null;
// Sort the input keys // Sort the input keys
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
keys.Sort(SplitByLevelSort); keys.Sort(SplitByLevelSort);
// Then, we loop over the games // Then, we loop over the games
@@ -366,7 +359,7 @@ namespace SabreTools.Helper.Dats
} }
// Clean the input list and set all games to be pathless // Clean the input list and set all games to be pathless
List<DatItem> items = Files[key]; List<DatItem> items = this[key];
items.ForEach(item => item.Machine.Name = Style.GetFileName(item.Machine.Name)); items.ForEach(item => item.Machine.Name = Style.GetFileName(item.Machine.Name));
items.ForEach(item => item.Machine.Description = Style.GetFileName(item.Machine.Description)); items.ForEach(item => item.Machine.Description = Style.GetFileName(item.Machine.Description));
@@ -472,7 +465,6 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
DatFile diskdat = new DatFile DatFile diskdat = new DatFile
{ {
@@ -494,7 +486,6 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
DatFile sampledat = new DatFile DatFile sampledat = new DatFile
{ {
@@ -516,14 +507,13 @@ namespace SabreTools.Helper.Dats
ForcePacking = this.ForcePacking, ForcePacking = this.ForcePacking,
DatFormat = this.DatFormat, DatFormat = this.DatFormat,
MergeRoms = this.MergeRoms, MergeRoms = this.MergeRoms,
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
// Now populate each of the DAT objects in turn // Now populate each of the DAT objects in turn
List<string> keys = this.Files.Keys.ToList(); List<string> keys = Keys.ToList();
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = this.Files[key]; List<DatItem> roms = this[key];
foreach (DatItem rom in roms) foreach (DatItem rom in roms)
{ {
// If the file is a Rom // If the file is a Rom
@@ -557,15 +547,15 @@ namespace SabreTools.Helper.Dats
// Now, output all of the files to the output directory // Now, output all of the files to the output directory
logger.User("DAT information created, outputting new files"); logger.User("DAT information created, outputting new files");
bool success = true; bool success = true;
if (romdat.Files.Count > 0) if (romdat.Count > 0)
{ {
success &= romdat.WriteToFile(outDir, logger); success &= romdat.WriteToFile(outDir, logger);
} }
if (diskdat.Files.Count > 0) if (diskdat.Count > 0)
{ {
success &= diskdat.WriteToFile(outDir, logger); success &= diskdat.WriteToFile(outDir, logger);
} }
if (sampledat.Files.Count > 0) if (sampledat.Count > 0)
{ {
success &= sampledat.WriteToFile(outDir, logger); success &= sampledat.WriteToFile(outDir, logger);
} }

View File

@@ -41,14 +41,15 @@ namespace SabreTools.Helper.Dats
NodumpCount = 0; NodumpCount = 0;
// If we have a blank Dat in any way, return // If we have a blank Dat in any way, return
if (this == null || Files == null || Files.Count == 0) if (this == null || Count == 0)
{ {
return; return;
} }
// Loop through and add // Loop through and add
foreach (List<DatItem> roms in Files.Values) foreach (string key in Keys)
{ {
List<DatItem> roms = this[key];
foreach (Rom rom in roms) foreach (Rom rom in roms)
{ {
RomCount += (rom.Type == ItemType.Rom ? 1 : 0); RomCount += (rom.Type == ItemType.Rom ? 1 : 0);
@@ -101,7 +102,7 @@ namespace SabreTools.Helper.Dats
string results = @"For '" + FileName + @"': string results = @"For '" + FileName + @"':
-------------------------------------------------- --------------------------------------------------
Uncompressed size: " + Style.GetBytesReadable(TotalSize) + @" Uncompressed size: " + Style.GetBytesReadable(TotalSize) + @"
Games found: " + (game == -1 ? Files.Count : game) + @" Games found: " + (game == -1 ? Count : game) + @"
Roms found: " + RomCount + @" Roms found: " + RomCount + @"
Disks found: " + DiskCount + @" Disks found: " + DiskCount + @"
Roms with CRC: " + CRCCount + @" Roms with CRC: " + CRCCount + @"
@@ -126,7 +127,7 @@ namespace SabreTools.Helper.Dats
case StatDatFormat.CSV: case StatDatFormat.CSV:
line = "\"" + FileName + "\"," line = "\"" + FileName + "\","
+ "\"" + Style.GetBytesReadable(TotalSize) + "\"," + "\"" + Style.GetBytesReadable(TotalSize) + "\","
+ "\"" + (game == -1 ? Files.Count : game) + "\"," + "\"" + (game == -1 ? Count : game) + "\","
+ "\"" + RomCount + "\"," + "\"" + RomCount + "\","
+ "\"" + DiskCount + "\"," + "\"" + DiskCount + "\","
+ "\"" + CRCCount + "\"," + "\"" + CRCCount + "\","
@@ -149,7 +150,7 @@ namespace SabreTools.Helper.Dats
? " class=\"dir\"><td>" + HttpUtility.HtmlEncode(FileName.Remove(0, 5)) ? " class=\"dir\"><td>" + HttpUtility.HtmlEncode(FileName.Remove(0, 5))
: "><td>" + HttpUtility.HtmlEncode(FileName)) + "</td>" : "><td>" + HttpUtility.HtmlEncode(FileName)) + "</td>"
+ "<td align=\"right\">" + Style.GetBytesReadable(TotalSize) + "</td>" + "<td align=\"right\">" + Style.GetBytesReadable(TotalSize) + "</td>"
+ "<td align=\"right\">" + (game == -1 ? Files.Count : game) + "</td>" + "<td align=\"right\">" + (game == -1 ? Count : game) + "</td>"
+ "<td align=\"right\">" + RomCount + "</td>" + "<td align=\"right\">" + RomCount + "</td>"
+ "<td align=\"right\">" + DiskCount + "</td>" + "<td align=\"right\">" + DiskCount + "</td>"
+ "<td align=\"right\">" + CRCCount + "</td>" + "<td align=\"right\">" + CRCCount + "</td>"
@@ -172,7 +173,7 @@ namespace SabreTools.Helper.Dats
line = @"'" + FileName + @"': line = @"'" + FileName + @"':
-------------------------------------------------- --------------------------------------------------
Uncompressed size: " + Style.GetBytesReadable(TotalSize) + @" Uncompressed size: " + Style.GetBytesReadable(TotalSize) + @"
Games found: " + (game == -1 ? Files.Count : game) + @" Games found: " + (game == -1 ? Count : game) + @"
Roms found: " + RomCount + @" Roms found: " + RomCount + @"
Disks found: " + DiskCount + @" Disks found: " + DiskCount + @"
Roms with CRC: " + CRCCount + @" Roms with CRC: " + CRCCount + @"
@@ -191,7 +192,7 @@ namespace SabreTools.Helper.Dats
case StatDatFormat.TSV: case StatDatFormat.TSV:
line = "\"" + FileName + "\"\t" line = "\"" + FileName + "\"\t"
+ "\"" + Style.GetBytesReadable(TotalSize) + "\"\t" + "\"" + Style.GetBytesReadable(TotalSize) + "\"\t"
+ "\"" + (game == -1 ? Files.Count : game) + "\"\t" + "\"" + (game == -1 ? Count : game) + "\"\t"
+ "\"" + RomCount + "\"\t" + "\"" + RomCount + "\"\t"
+ "\"" + DiskCount + "\"\t" + "\"" + DiskCount + "\"\t"
+ "\"" + CRCCount + "\"\t" + "\"" + CRCCount + "\"\t"
@@ -347,7 +348,7 @@ namespace SabreTools.Helper.Dats
// Add single DAT stats to dir // Add single DAT stats to dir
dirSize += datdata.TotalSize; dirSize += datdata.TotalSize;
dirGame += datdata.Files.Count; dirGame += datdata.Count;
dirRom += datdata.RomCount; dirRom += datdata.RomCount;
dirDisk += datdata.DiskCount; dirDisk += datdata.DiskCount;
dirCRC += datdata.CRCCount; dirCRC += datdata.CRCCount;
@@ -358,7 +359,7 @@ namespace SabreTools.Helper.Dats
// Add single DAT stats to totals // Add single DAT stats to totals
totalSize += datdata.TotalSize; totalSize += datdata.TotalSize;
totalGame += datdata.Files.Count; totalGame += datdata.Count;
totalRom += datdata.RomCount; totalRom += datdata.RomCount;
totalDisk += datdata.DiskCount; totalDisk += datdata.DiskCount;
totalCRC += datdata.CRCCount; totalCRC += datdata.CRCCount;

View File

@@ -42,7 +42,7 @@ namespace SabreTools.Helper.Dats
public bool WriteToFile(string outDir, Logger logger, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true) public bool WriteToFile(string outDir, Logger logger, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true)
{ {
// If there's nothing there, abort // If there's nothing there, abort
if (Files == null || Files.Count == 0) if (Count == 0)
{ {
return false; return false;
} }
@@ -116,7 +116,7 @@ namespace SabreTools.Helper.Dats
try try
{ {
// Get a properly sorted set of keys // Get a properly sorted set of keys
List<string> keys = Files.Keys.ToList(); List<string> keys = Keys.ToList();
keys.Sort(new NaturalComparer()); keys.Sort(new NaturalComparer());
foreach (DatFormat datFormat in outfiles.Keys) foreach (DatFormat datFormat in outfiles.Keys)
@@ -137,7 +137,7 @@ namespace SabreTools.Helper.Dats
foreach (string key in keys) foreach (string key in keys)
{ {
List<DatItem> roms = Files[key]; List<DatItem> roms = this[key];
for (int index = 0; index < roms.Count; index++) for (int index = 0; index < roms.Count; index++)
{ {
@@ -310,7 +310,7 @@ namespace SabreTools.Helper.Dats
+ "<dat xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"datas.xsd\">\n" + "<dat xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"datas.xsd\">\n"
+ "\t<configuration>\n" + "\t<configuration>\n"
+ "\t\t<datName>" + HttpUtility.HtmlEncode(Name) + "</datName>\n" + "\t\t<datName>" + HttpUtility.HtmlEncode(Name) + "</datName>\n"
+ "\t\t<datVersion>" + Files.Count + "</datVersion>\n" + "\t\t<datVersion>" + Count + "</datVersion>\n"
+ "\t\t<system>none</system>\n" + "\t\t<system>none</system>\n"
+ "\t\t<screenshotsWidth>240</screenshotsWidth>\n" + "\t\t<screenshotsWidth>240</screenshotsWidth>\n"
+ "\t\t<screenshotsHeight>160</screenshotsHeight>\n" + "\t\t<screenshotsHeight>160</screenshotsHeight>\n"
@@ -1290,7 +1290,7 @@ namespace SabreTools.Helper.Dats
string footer = ""; string footer = "";
// If we have roms, output the full footer // If we have roms, output the full footer
if (Files != null && Files.Count > 0) if (Count > 0)
{ {
switch (datFormat) switch (datFormat)
{ {

View File

@@ -102,7 +102,6 @@ namespace SabreTools
Romba = romba, Romba = romba,
ExcludeOf = excludeOf, ExcludeOf = excludeOf,
Type = (superdat ? "SuperDAT" : ""), Type = (superdat ? "SuperDAT" : ""),
Files = new SortedDictionary<string, List<DatItem>>(),
}; };
// Clean the temp directory // Clean the temp directory
@@ -115,7 +114,7 @@ namespace SabreTools
{ {
// Clone the base Dat for information // Clone the base Dat for information
DatFile datdata = (DatFile)basedat.Clone(); DatFile datdata = (DatFile)basedat.Clone();
datdata.Files = new SortedDictionary<string, List<DatItem>>(); datdata.Reset();
string basePath = Path.GetFullPath(path); string basePath = Path.GetFullPath(path);
bool success = datdata.PopulateFromDir(basePath, noMD5, noSHA1, removeDateFromAutomaticName, parseArchivesAsFiles, enableGzip, bool success = datdata.PopulateFromDir(basePath, noMD5, noSHA1, removeDateFromAutomaticName, parseArchivesAsFiles, enableGzip,