2016-10-24 12:58:57 -07:00
|
|
|
|
using System;
|
2016-04-19 01:11:23 -07:00
|
|
|
|
using System.Collections.Generic;
|
2016-10-24 13:51:39 -07:00
|
|
|
|
|
2016-10-24 12:58:57 -07:00
|
|
|
|
using SabreTools.Helper.Data;
|
2016-10-26 22:10:47 -07:00
|
|
|
|
|
2016-10-24 12:58:57 -07:00
|
|
|
|
namespace SabreTools.Helper.Dats
|
2016-04-19 01:11:23 -07:00
|
|
|
|
{
|
2016-11-08 16:04:26 -08:00
|
|
|
|
public partial class DatFile
|
2016-04-19 01:11:23 -07:00
|
|
|
|
{
|
2016-09-19 20:08:25 -07:00
|
|
|
|
#region Private instance variables
|
|
|
|
|
|
|
|
|
|
|
|
// Data common to most DAT types
|
|
|
|
|
|
private string _fileName;
|
|
|
|
|
|
private string _name;
|
|
|
|
|
|
private string _description;
|
|
|
|
|
|
private string _rootDir;
|
|
|
|
|
|
private string _category;
|
|
|
|
|
|
private string _version;
|
|
|
|
|
|
private string _date;
|
|
|
|
|
|
private string _author;
|
|
|
|
|
|
private string _email;
|
|
|
|
|
|
private string _homepage;
|
|
|
|
|
|
private string _url;
|
|
|
|
|
|
private string _comment;
|
|
|
|
|
|
private string _header;
|
|
|
|
|
|
private string _type; // Generally only used for SuperDAT
|
|
|
|
|
|
private ForceMerging _forceMerging;
|
|
|
|
|
|
private ForceNodump _forceNodump;
|
|
|
|
|
|
private ForcePacking _forcePacking;
|
2016-10-25 15:02:02 -07:00
|
|
|
|
private DatFormat _datFormat;
|
2016-10-04 10:26:19 -07:00
|
|
|
|
private bool _excludeOf;
|
2016-09-19 20:08:25 -07:00
|
|
|
|
private bool _mergeRoms;
|
2017-02-26 22:41:17 -08:00
|
|
|
|
private Hash _stripHash;
|
2017-02-27 21:53:20 -08:00
|
|
|
|
private bool _oneGameOneRegion;
|
|
|
|
|
|
private List<string> _regions = new List<string>();
|
2016-12-01 11:43:09 -08:00
|
|
|
|
private SortedDictionary<string, List<DatItem>> _files = new SortedDictionary<string, List<DatItem>>();
|
2016-10-06 11:42:55 -07:00
|
|
|
|
private SortedBy _sortedBy;
|
2016-09-19 20:08:25 -07:00
|
|
|
|
|
|
|
|
|
|
// Data specific to the Miss DAT type
|
|
|
|
|
|
private bool _useGame;
|
|
|
|
|
|
private string _prefix;
|
|
|
|
|
|
private string _postfix;
|
|
|
|
|
|
private bool _quotes;
|
|
|
|
|
|
private string _repExt;
|
|
|
|
|
|
private string _addExt;
|
|
|
|
|
|
private bool _remExt;
|
|
|
|
|
|
private bool _gameName;
|
|
|
|
|
|
private bool _romba;
|
|
|
|
|
|
|
|
|
|
|
|
// Statistical data related to the DAT
|
|
|
|
|
|
private long _romCount;
|
|
|
|
|
|
private long _diskCount;
|
|
|
|
|
|
private long _totalSize;
|
|
|
|
|
|
private long _crcCount;
|
|
|
|
|
|
private long _md5Count;
|
|
|
|
|
|
private long _sha1Count;
|
2017-02-23 14:23:41 -08:00
|
|
|
|
private long _sha256Count;
|
2017-02-27 00:01:24 -08:00
|
|
|
|
private long _sha384Count;
|
|
|
|
|
|
private long _sha512Count;
|
2016-09-26 16:42:06 -07:00
|
|
|
|
private long _baddumpCount;
|
|
|
|
|
|
private long _nodumpCount;
|
2016-09-19 20:08:25 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Publicly facing variables
|
|
|
|
|
|
|
|
|
|
|
|
// Data common to most DAT types
|
|
|
|
|
|
public string FileName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _fileName; }
|
|
|
|
|
|
set { _fileName = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _name; }
|
|
|
|
|
|
set { _name = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Description
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _description; }
|
|
|
|
|
|
set { _description = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string RootDir
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _rootDir; }
|
|
|
|
|
|
set { _rootDir = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Category
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _category; }
|
|
|
|
|
|
set { _category = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Version
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _version; }
|
|
|
|
|
|
set { _version = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Date
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _date; }
|
|
|
|
|
|
set { _date = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Author
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _author; }
|
|
|
|
|
|
set { _author = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Email
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _email; }
|
|
|
|
|
|
set { _email = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Homepage
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _homepage; }
|
|
|
|
|
|
set { _homepage = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Url
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _url; }
|
|
|
|
|
|
set { _url = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Comment
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _comment; }
|
|
|
|
|
|
set { _comment = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Header
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _header; }
|
|
|
|
|
|
set { _header = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Type // Generally only used for SuperDAT
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _type; }
|
|
|
|
|
|
set { _type = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public ForceMerging ForceMerging
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _forceMerging; }
|
|
|
|
|
|
set { _forceMerging = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public ForceNodump ForceNodump
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _forceNodump; }
|
|
|
|
|
|
set { _forceNodump = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public ForcePacking ForcePacking
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _forcePacking; }
|
|
|
|
|
|
set { _forcePacking = value; }
|
|
|
|
|
|
}
|
2016-10-25 15:02:02 -07:00
|
|
|
|
public DatFormat DatFormat
|
2016-09-19 20:08:25 -07:00
|
|
|
|
{
|
2016-10-25 15:02:02 -07:00
|
|
|
|
get { return _datFormat; }
|
|
|
|
|
|
set { _datFormat = value; }
|
2016-09-19 20:08:25 -07:00
|
|
|
|
}
|
2016-10-04 10:26:19 -07:00
|
|
|
|
public bool ExcludeOf
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _excludeOf; }
|
|
|
|
|
|
set { _excludeOf = value; }
|
|
|
|
|
|
}
|
2016-09-19 20:08:25 -07:00
|
|
|
|
public bool MergeRoms
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _mergeRoms; }
|
|
|
|
|
|
set { _mergeRoms = value; }
|
|
|
|
|
|
}
|
2017-02-26 22:41:17 -08:00
|
|
|
|
public Hash StripHash
|
2017-02-25 20:35:06 -08:00
|
|
|
|
{
|
|
|
|
|
|
get { return _stripHash; }
|
|
|
|
|
|
set { _stripHash = value; }
|
|
|
|
|
|
}
|
2017-02-27 21:53:20 -08:00
|
|
|
|
public bool OneGameOneRegion
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _oneGameOneRegion; }
|
|
|
|
|
|
set { _oneGameOneRegion = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<string> Regions
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _regions; }
|
|
|
|
|
|
set { _regions = value; }
|
|
|
|
|
|
}
|
2016-10-06 11:42:55 -07:00
|
|
|
|
public SortedBy SortedBy
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _sortedBy; }
|
|
|
|
|
|
set { _sortedBy = value; }
|
|
|
|
|
|
}
|
2016-09-19 20:08:25 -07:00
|
|
|
|
|
|
|
|
|
|
// Data specific to the Miss DAT type
|
|
|
|
|
|
public bool UseGame
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _useGame; }
|
|
|
|
|
|
set { _useGame = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Prefix
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _prefix; }
|
|
|
|
|
|
set { _prefix = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Postfix
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _postfix; }
|
|
|
|
|
|
set { _postfix = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool Quotes
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _quotes; }
|
|
|
|
|
|
set { _quotes = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string RepExt
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _repExt; }
|
|
|
|
|
|
set { _repExt = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string AddExt
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _addExt; }
|
|
|
|
|
|
set { _addExt = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool RemExt
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _remExt; }
|
|
|
|
|
|
set { _remExt = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool GameName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _gameName; }
|
|
|
|
|
|
set { _gameName = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool Romba
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _romba; }
|
|
|
|
|
|
set { _romba = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Statistical data related to the DAT
|
|
|
|
|
|
public long RomCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _romCount; }
|
|
|
|
|
|
set { _romCount = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public long DiskCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _diskCount; }
|
|
|
|
|
|
set { _diskCount = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public long TotalSize
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _totalSize; }
|
|
|
|
|
|
set { _totalSize = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public long CRCCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _crcCount; }
|
|
|
|
|
|
set { _crcCount = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public long MD5Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _md5Count; }
|
|
|
|
|
|
set { _md5Count = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public long SHA1Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _sha1Count; }
|
|
|
|
|
|
set { _sha1Count = value; }
|
|
|
|
|
|
}
|
2017-02-23 14:34:01 -08:00
|
|
|
|
public long SHA256Count
|
2017-02-23 14:23:41 -08:00
|
|
|
|
{
|
|
|
|
|
|
get { return _sha256Count; }
|
|
|
|
|
|
set { _sha256Count = value; }
|
|
|
|
|
|
}
|
2017-02-27 00:01:24 -08:00
|
|
|
|
public long SHA384Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _sha384Count; }
|
|
|
|
|
|
set { _sha384Count = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public long SHA512Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _sha512Count; }
|
|
|
|
|
|
set { _sha512Count = value; }
|
|
|
|
|
|
}
|
2016-09-26 16:42:06 -07:00
|
|
|
|
public long BaddumpCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _baddumpCount; }
|
|
|
|
|
|
set { _baddumpCount = value; }
|
|
|
|
|
|
}
|
2016-09-19 20:08:25 -07:00
|
|
|
|
public long NodumpCount
|
|
|
|
|
|
{
|
2016-09-26 16:42:06 -07:00
|
|
|
|
get { return _nodumpCount; }
|
|
|
|
|
|
set { _nodumpCount = value; }
|
2016-09-19 20:08:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-10-06 11:42:55 -07:00
|
|
|
|
#region Instance Methods
|
|
|
|
|
|
|
2016-11-08 15:29:52 -08:00
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Passthrough to access the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">Key in the dictionary to reference</param>
|
|
|
|
|
|
public List<DatItem> this[string key]
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the key is missing from the dictionary, add it
|
|
|
|
|
|
if (!_files.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
_files.Add(key, new List<DatItem>());
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// Now return the value
|
|
|
|
|
|
return _files[key];
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the key is missing from the dictionary, add it
|
|
|
|
|
|
if (!_files.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
_files.Add(key, new List<DatItem>());
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// Now set the value
|
|
|
|
|
|
_files[key] = value;
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Add a new key to the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">Key in the dictionary to add to</param>
|
|
|
|
|
|
public void Add(string key)
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2016-11-08 15:29:52 -08:00
|
|
|
|
// If the key is missing from the dictionary, add it
|
|
|
|
|
|
if (!_files.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
_files.Add(key, new List<DatItem>());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Add a value to the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">Key in the dictionary to add to</param>
|
|
|
|
|
|
/// <param name="value">Value to add to the dictionary</param>
|
|
|
|
|
|
public void Add(string key, DatItem value)
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2016-11-08 15:29:52 -08:00
|
|
|
|
// If the key is missing from the dictionary, add it
|
|
|
|
|
|
if (!_files.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
_files.Add(key, new List<DatItem>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now add the value
|
|
|
|
|
|
_files[key].Add(value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Add a range of values to the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">Key in the dictionary to add to</param>
|
|
|
|
|
|
/// <param name="value">Value to add to the dictionary</param>
|
|
|
|
|
|
public void AddRange(string key, List<DatItem> value)
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2016-11-08 15:29:52 -08:00
|
|
|
|
// If the key is missing from the dictionary, add it
|
|
|
|
|
|
if (!_files.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
_files.Add(key, new List<DatItem>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now add the value
|
|
|
|
|
|
_files[key].AddRange(value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get if the file dictionary contains the key
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">Key in the dictionary to check</param>
|
|
|
|
|
|
/// <returns>True if the key exists, false otherwise</returns>
|
|
|
|
|
|
public bool ContainsKey(string key)
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2016-11-08 15:29:52 -08:00
|
|
|
|
return _files.ContainsKey(key);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-03-01 19:55:42 -08:00
|
|
|
|
/// Get the number of DatItems in the file dictionary
|
2016-11-08 15:29:52 -08:00
|
|
|
|
/// </summary>
|
2017-03-01 19:55:42 -08:00
|
|
|
|
/// <returns>Number of DatItems in the file dictionary</returns>
|
2016-11-08 15:29:52 -08:00
|
|
|
|
public long Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2017-01-25 10:47:05 -08:00
|
|
|
|
int count = 0;
|
|
|
|
|
|
foreach (string key in _files.Keys)
|
|
|
|
|
|
{
|
|
|
|
|
|
count += _files[key].Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return count;
|
2016-11-08 15:29:52 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-11-08 15:50:27 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Delete the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Delete()
|
|
|
|
|
|
{
|
|
|
|
|
|
_files = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-11-08 15:29:52 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get the keys from the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>IEnumerable of the keys</returns>
|
|
|
|
|
|
public IEnumerable<string> Keys
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2016-11-08 15:29:52 -08:00
|
|
|
|
return _files.Keys;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Remove a key from the file dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
|
public void Remove(string key)
|
|
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
// If the dictionary is null, create it
|
|
|
|
|
|
if (_files == null)
|
2016-11-08 15:29:52 -08:00
|
|
|
|
{
|
2016-12-01 11:43:09 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
2016-11-08 15:29:52 -08:00
|
|
|
|
|
2016-12-01 11:43:09 -08:00
|
|
|
|
lock (_files)
|
|
|
|
|
|
{
|
2016-11-08 15:29:52 -08:00
|
|
|
|
// If the key is in the dictionary, remove it
|
|
|
|
|
|
if (_files.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
_files.Remove(key);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-11-08 15:50:27 -08:00
|
|
|
|
/// <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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-11-08 15:29:52 -08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-11-08 16:04:26 -08:00
|
|
|
|
#region Constructors
|
2016-09-19 20:08:25 -07:00
|
|
|
|
|
2016-11-08 16:04:26 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new, empty DatFile object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DatFile()
|
2016-09-19 20:08:25 -07:00
|
|
|
|
{
|
2016-11-08 16:04:26 -08:00
|
|
|
|
_files = new SortedDictionary<string, List<DatItem>>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new DatFile from an existing one
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="df"></param>
|
|
|
|
|
|
public DatFile(DatFile datFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
_fileName = datFile.FileName;
|
|
|
|
|
|
_name = datFile.Name;
|
|
|
|
|
|
_description = datFile.Description;
|
|
|
|
|
|
_rootDir = datFile.RootDir;
|
|
|
|
|
|
_category = datFile.Category;
|
|
|
|
|
|
_version = datFile.Version;
|
|
|
|
|
|
_date = datFile.Date;
|
|
|
|
|
|
_author = datFile.Author;
|
|
|
|
|
|
_email = datFile.Email;
|
|
|
|
|
|
_homepage = datFile.Homepage;
|
|
|
|
|
|
_url = datFile.Url;
|
|
|
|
|
|
_comment = datFile.Comment;
|
|
|
|
|
|
_header = datFile.Header;
|
|
|
|
|
|
_type = datFile.Type;
|
|
|
|
|
|
_forceMerging = datFile.ForceMerging;
|
|
|
|
|
|
_forceNodump = datFile.ForceNodump;
|
|
|
|
|
|
_forcePacking = datFile.ForcePacking;
|
|
|
|
|
|
_excludeOf = datFile.ExcludeOf;
|
|
|
|
|
|
_datFormat = datFile.DatFormat;
|
|
|
|
|
|
_mergeRoms = datFile.MergeRoms;
|
2017-02-25 20:35:06 -08:00
|
|
|
|
_stripHash = datFile.StripHash;
|
2016-11-08 16:04:26 -08:00
|
|
|
|
_sortedBy = SortedBy.Default;
|
|
|
|
|
|
_useGame = datFile.UseGame;
|
|
|
|
|
|
_prefix = datFile.Prefix;
|
|
|
|
|
|
_postfix = datFile.Postfix;
|
|
|
|
|
|
_quotes = datFile.Quotes;
|
|
|
|
|
|
_repExt = datFile.RepExt;
|
|
|
|
|
|
_addExt = datFile.AddExt;
|
|
|
|
|
|
_remExt = datFile.RemExt;
|
|
|
|
|
|
_gameName = datFile.GameName;
|
|
|
|
|
|
_romba = datFile.Romba;
|
2016-09-19 20:08:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-10-24 16:14:22 -07:00
|
|
|
|
#endregion // Instance Methods
|
2016-04-19 01:11:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|