mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Create Constants class and consolodate
This commit is contained in:
@@ -19,36 +19,6 @@ namespace SabreTools
|
|||||||
private string _connectionString;
|
private string _connectionString;
|
||||||
private Logger _logger;
|
private Logger _logger;
|
||||||
|
|
||||||
// Regex File Name Patterns
|
|
||||||
private static string _defaultPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.dat$";
|
|
||||||
private static string _defaultSpecialPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.xml$";
|
|
||||||
private static string _goodPattern = @"^(Good.*?)_.*\.dat";
|
|
||||||
private static string _goodXmlPattern = @"^(Good.*?)_.*\.xml";
|
|
||||||
private static string _mamePattern = @"^(.*)\.xml$";
|
|
||||||
private static string _maybeIntroPattern = @"(.*?) \[T-En\].*\((\d{8})\)\.dat$";
|
|
||||||
private static string _noIntroPattern = @"^(.*?) \((\d{8}-\d{6})_CM\)\.dat$";
|
|
||||||
private static string _noIntroNumberedPattern = @"(.*? - .*?) \(\d.*?_CM\).dat";
|
|
||||||
private static string _noIntroSpecialPattern = @"(.*? - .*?) \((\d{8})\)\.dat";
|
|
||||||
private static string _nonGoodPattern = @"^(NonGood.*?)( .*?)?.xml";
|
|
||||||
private static string _nonGoodSpecialPattern = @"^(NonGood.*?)( .*)?.dat";
|
|
||||||
private static string _redumpPattern = @"^(.*?) \((\d{8} \d{2}-\d{2}-\d{2})\)\.dat$";
|
|
||||||
private static string _redumpBiosPattern = @"^(.*?) \(\d+\) \((\d{4}-\d{2}-\d{2})\)\.dat$";
|
|
||||||
private static string _tosecPattern = @"^(.*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
|
||||||
private static string _tosecSpecialPatternA = @"^(.*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
|
||||||
private static string _tosecSpecialPatternB = @"^(.*? - .*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
|
||||||
private static string _truripPattern = @"^(.*) - .* \(trurip_XML\)\.dat$";
|
|
||||||
private static string _zandroPattern = @"^SMW-.*.xml";
|
|
||||||
|
|
||||||
// Regex Mapped Name Patterns
|
|
||||||
private static string _remappedPattern = @"^(.*) - (.*)$";
|
|
||||||
|
|
||||||
// Regex Date Patterns
|
|
||||||
private static string _defaultDatePattern = @"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})";
|
|
||||||
private static string _noIntroDatePattern = @"(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})";
|
|
||||||
private static string _noIntroSpecialDatePattern = @"(\d{4})(\d{2})(\d{2})";
|
|
||||||
private static string _redumpDatePattern = @"(\d{4})(\d{2})(\d{2}) (\d{2})-(\d{2})-(\d{2})";
|
|
||||||
private static string _tosecDatePattern = @"(\d{4})-(\d{2})-(\d{2})";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize an Import object with the given information
|
/// Initialize an Import object with the given information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -80,88 +50,88 @@ namespace SabreTools
|
|||||||
GroupCollection fileinfo;
|
GroupCollection fileinfo;
|
||||||
DatType type = DatType.none;
|
DatType type = DatType.none;
|
||||||
|
|
||||||
if (Regex.IsMatch(filename, _nonGoodPattern))
|
if (Regex.IsMatch(filename, Constants.NonGoodPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _nonGoodPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NonGoodPattern).Groups;
|
||||||
type = DatType.NonGood;
|
type = DatType.NonGood;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _nonGoodSpecialPattern))
|
else if (Regex.IsMatch(filename, Constants.NonGoodSpecialPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _nonGoodSpecialPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NonGoodSpecialPattern).Groups;
|
||||||
type = DatType.NonGood;
|
type = DatType.NonGood;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _goodPattern))
|
else if (Regex.IsMatch(filename, Constants.GoodPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _goodPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.GoodPattern).Groups;
|
||||||
type = DatType.Good;
|
type = DatType.Good;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _goodXmlPattern))
|
else if (Regex.IsMatch(filename, Constants.GoodXmlPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _goodXmlPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.GoodXmlPattern).Groups;
|
||||||
type = DatType.Good;
|
type = DatType.Good;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _maybeIntroPattern))
|
else if (Regex.IsMatch(filename, Constants.MaybeIntroPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _maybeIntroPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.MaybeIntroPattern).Groups;
|
||||||
type = DatType.MaybeIntro;
|
type = DatType.MaybeIntro;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _noIntroPattern))
|
else if (Regex.IsMatch(filename, Constants.NoIntroPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _noIntroPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NoIntroPattern).Groups;
|
||||||
type = DatType.NoIntro;
|
type = DatType.NoIntro;
|
||||||
}
|
}
|
||||||
// For numbered DATs only
|
// For numbered DATs only
|
||||||
else if (Regex.IsMatch(filename, _noIntroNumberedPattern))
|
else if (Regex.IsMatch(filename, Constants.NoIntroNumberedPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _noIntroNumberedPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NoIntroNumberedPattern).Groups;
|
||||||
type = DatType.NoIntro;
|
type = DatType.NoIntro;
|
||||||
}
|
}
|
||||||
// For N-Gage and Gizmondo only
|
// For N-Gage and Gizmondo only
|
||||||
else if (Regex.IsMatch(filename, _noIntroSpecialPattern))
|
else if (Regex.IsMatch(filename, Constants.NoIntroSpecialPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _noIntroSpecialPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NoIntroSpecialPattern).Groups;
|
||||||
type = DatType.NoIntro;
|
type = DatType.NoIntro;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _redumpPattern))
|
else if (Regex.IsMatch(filename, Constants.RedumpPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _redumpPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.RedumpPattern).Groups;
|
||||||
type = DatType.Redump;
|
type = DatType.Redump;
|
||||||
}
|
}
|
||||||
// For special BIOSes only
|
// For special BIOSes only
|
||||||
else if (Regex.IsMatch(filename, _redumpBiosPattern))
|
else if (Regex.IsMatch(filename, Constants.RedumpBiosPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _redumpBiosPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.RedumpBiosPattern).Groups;
|
||||||
type = DatType.Redump;
|
type = DatType.Redump;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _tosecPattern))
|
else if (Regex.IsMatch(filename, Constants.TosecPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _tosecPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.TosecPattern).Groups;
|
||||||
type = DatType.TOSEC;
|
type = DatType.TOSEC;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _truripPattern))
|
else if (Regex.IsMatch(filename, Constants.TruripPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _truripPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.TruripPattern).Groups;
|
||||||
type = DatType.TruRip;
|
type = DatType.TruRip;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _zandroPattern))
|
else if (Regex.IsMatch(filename, Constants.ZandroPattern))
|
||||||
{
|
{
|
||||||
filename = "Nintendo - Super Nintendo Entertainment System (Zandro " + File.GetLastWriteTime(_filepath).ToString("yyyyMMddHHmmss") + ").dat";
|
filename = "Nintendo - Super Nintendo Entertainment System (Zandro " + File.GetLastWriteTime(_filepath).ToString("yyyyMMddHHmmss") + ").dat";
|
||||||
fileinfo = Regex.Match(filename, _defaultPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.DefaultPattern).Groups;
|
||||||
type = DatType.Custom;
|
type = DatType.Custom;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _defaultPattern))
|
else if (Regex.IsMatch(filename, Constants.DefaultPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _defaultPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.DefaultPattern).Groups;
|
||||||
type = DatType.Custom;
|
type = DatType.Custom;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _defaultSpecialPattern))
|
else if (Regex.IsMatch(filename, Constants.DefaultSpecialPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _defaultSpecialPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.DefaultSpecialPattern).Groups;
|
||||||
type = DatType.Custom;
|
type = DatType.Custom;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _mamePattern))
|
else if (Regex.IsMatch(filename, Constants.MamePattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _mamePattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.MamePattern).Groups;
|
||||||
type = DatType.MAME;
|
type = DatType.MAME;
|
||||||
}
|
}
|
||||||
// If the type is still unmatched, the data can't be imported yet
|
// If the type is still unmatched, the data can't be imported yet
|
||||||
@@ -188,7 +158,7 @@ namespace SabreTools
|
|||||||
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GroupCollection goodInfo = Regex.Match(Remapping.Good[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection goodInfo = Regex.Match(Remapping.Good[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = goodInfo[1].Value;
|
manufacturer = goodInfo[1].Value;
|
||||||
system = goodInfo[2].Value;
|
system = goodInfo[2].Value;
|
||||||
@@ -201,7 +171,7 @@ namespace SabreTools
|
|||||||
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GroupCollection mameInfo = Regex.Match(Remapping.MAME[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection mameInfo = Regex.Match(Remapping.MAME[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = mameInfo[1].Value;
|
manufacturer = mameInfo[1].Value;
|
||||||
system = mameInfo[2].Value;
|
system = mameInfo[2].Value;
|
||||||
@@ -214,13 +184,13 @@ namespace SabreTools
|
|||||||
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GroupCollection maybeIntroInfo = Regex.Match(Remapping.MaybeIntro[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection maybeIntroInfo = Regex.Match(Remapping.MaybeIntro[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = maybeIntroInfo[1].Value;
|
manufacturer = maybeIntroInfo[1].Value;
|
||||||
system = maybeIntroInfo[2].Value;
|
system = maybeIntroInfo[2].Value;
|
||||||
source = "Maybe-Intro";
|
source = "Maybe-Intro";
|
||||||
datestring = fileinfo[2].Value;
|
datestring = fileinfo[2].Value;
|
||||||
GroupCollection miDateInfo = Regex.Match(datestring, _noIntroSpecialDatePattern).Groups;
|
GroupCollection miDateInfo = Regex.Match(datestring, Constants.NoIntroSpecialDatePattern).Groups;
|
||||||
date = miDateInfo[1].Value + "-" + miDateInfo[2].Value + "-" + miDateInfo[3].Value + " 00:00:00";
|
date = miDateInfo[1].Value + "-" + miDateInfo[2].Value + "-" + miDateInfo[3].Value + " 00:00:00";
|
||||||
break;
|
break;
|
||||||
case DatType.NoIntro:
|
case DatType.NoIntro:
|
||||||
@@ -229,7 +199,7 @@ namespace SabreTools
|
|||||||
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GroupCollection nointroInfo = Regex.Match(Remapping.NoIntro[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection nointroInfo = Regex.Match(Remapping.NoIntro[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = nointroInfo[1].Value;
|
manufacturer = nointroInfo[1].Value;
|
||||||
system = nointroInfo[2].Value;
|
system = nointroInfo[2].Value;
|
||||||
@@ -238,17 +208,17 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
date = File.GetLastWriteTime(_filepath).ToString("yyyy-MM-dd HH:mm:ss");
|
date = File.GetLastWriteTime(_filepath).ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(fileinfo[2].Value, _noIntroDatePattern))
|
else if (Regex.IsMatch(fileinfo[2].Value, Constants.NoIntroDatePattern))
|
||||||
{
|
{
|
||||||
datestring = fileinfo[2].Value;
|
datestring = fileinfo[2].Value;
|
||||||
GroupCollection niDateInfo = Regex.Match(datestring, _noIntroDatePattern).Groups;
|
GroupCollection niDateInfo = Regex.Match(datestring, Constants.NoIntroDatePattern).Groups;
|
||||||
date = niDateInfo[1].Value + "-" + niDateInfo[2].Value + "-" + niDateInfo[3].Value + " " +
|
date = niDateInfo[1].Value + "-" + niDateInfo[2].Value + "-" + niDateInfo[3].Value + " " +
|
||||||
niDateInfo[4].Value + ":" + niDateInfo[5].Value + ":" + niDateInfo[6].Value;
|
niDateInfo[4].Value + ":" + niDateInfo[5].Value + ":" + niDateInfo[6].Value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
datestring = fileinfo[2].Value;
|
datestring = fileinfo[2].Value;
|
||||||
GroupCollection niDateInfo = Regex.Match(datestring, _noIntroSpecialDatePattern).Groups;
|
GroupCollection niDateInfo = Regex.Match(datestring, Constants.NoIntroSpecialDatePattern).Groups;
|
||||||
date = niDateInfo[1].Value + "-" + niDateInfo[2].Value + "-" + niDateInfo[3].Value + " 00:00:00";
|
date = niDateInfo[1].Value + "-" + niDateInfo[2].Value + "-" + niDateInfo[3].Value + " 00:00:00";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -258,7 +228,7 @@ namespace SabreTools
|
|||||||
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GroupCollection nonGoodInfo = Regex.Match(Remapping.NonGood[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection nonGoodInfo = Regex.Match(Remapping.NonGood[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = nonGoodInfo[1].Value;
|
manufacturer = nonGoodInfo[1].Value;
|
||||||
system = nonGoodInfo[2].Value;
|
system = nonGoodInfo[2].Value;
|
||||||
@@ -269,7 +239,7 @@ namespace SabreTools
|
|||||||
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
// Handle special case mappings found only in Redump
|
// Handle special case mappings found only in Redump
|
||||||
fileinfo = Regex.Match(filename, _redumpBiosPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.RedumpBiosPattern).Groups;
|
||||||
|
|
||||||
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
@@ -277,21 +247,21 @@ namespace SabreTools
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupCollection redumpInfo = Regex.Match(Remapping.Redump[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection redumpInfo = Regex.Match(Remapping.Redump[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = redumpInfo[1].Value;
|
manufacturer = redumpInfo[1].Value;
|
||||||
system = redumpInfo[2].Value;
|
system = redumpInfo[2].Value;
|
||||||
source = "Redump";
|
source = "Redump";
|
||||||
datestring = fileinfo[2].Value;
|
datestring = fileinfo[2].Value;
|
||||||
if (Regex.IsMatch(datestring, _redumpDatePattern))
|
if (Regex.IsMatch(datestring, Constants.RedumpDatePattern))
|
||||||
{
|
{
|
||||||
GroupCollection rdDateInfo = Regex.Match(datestring, _redumpDatePattern).Groups;
|
GroupCollection rdDateInfo = Regex.Match(datestring, Constants.RedumpDatePattern).Groups;
|
||||||
date = rdDateInfo[1].Value + "-" + rdDateInfo[2].Value + "-" + rdDateInfo[3].Value + " " +
|
date = rdDateInfo[1].Value + "-" + rdDateInfo[2].Value + "-" + rdDateInfo[3].Value + " " +
|
||||||
rdDateInfo[4].Value + ":" + rdDateInfo[5].Value + ":" + rdDateInfo[6].Value;
|
rdDateInfo[4].Value + ":" + rdDateInfo[5].Value + ":" + rdDateInfo[6].Value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GroupCollection rdDateInfo = Regex.Match(datestring, _tosecDatePattern).Groups;
|
GroupCollection rdDateInfo = Regex.Match(datestring, Constants.TosecDatePattern).Groups;
|
||||||
date = rdDateInfo[1].Value + "-" + rdDateInfo[2].Value + "-" + rdDateInfo[3].Value + " 00:00:00";
|
date = rdDateInfo[1].Value + "-" + rdDateInfo[2].Value + "-" + rdDateInfo[3].Value + " 00:00:00";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,11 +270,11 @@ namespace SabreTools
|
|||||||
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
// Handle special case mappings found only in TOSEC
|
// Handle special case mappings found only in TOSEC
|
||||||
fileinfo = Regex.Match(filename, _tosecSpecialPatternA).Groups;
|
fileinfo = Regex.Match(filename, Constants.TosecSpecialPatternA).Groups;
|
||||||
|
|
||||||
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _tosecSpecialPatternB).Groups;
|
fileinfo = Regex.Match(filename, Constants.TosecSpecialPatternB).Groups;
|
||||||
|
|
||||||
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
@@ -313,13 +283,13 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupCollection tosecInfo = Regex.Match(Remapping.TOSEC[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection tosecInfo = Regex.Match(Remapping.TOSEC[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = tosecInfo[1].Value;
|
manufacturer = tosecInfo[1].Value;
|
||||||
system = tosecInfo[2].Value;
|
system = tosecInfo[2].Value;
|
||||||
source = "TOSEC";
|
source = "TOSEC";
|
||||||
datestring = fileinfo[2].Value;
|
datestring = fileinfo[2].Value;
|
||||||
GroupCollection toDateInfo = Regex.Match(datestring, _tosecDatePattern).Groups;
|
GroupCollection toDateInfo = Regex.Match(datestring, Constants.TosecDatePattern).Groups;
|
||||||
date = toDateInfo[1].Value + "-" + toDateInfo[2].Value + "-" + toDateInfo[3].Value + " 00:00:00";
|
date = toDateInfo[1].Value + "-" + toDateInfo[2].Value + "-" + toDateInfo[3].Value + " 00:00:00";
|
||||||
break;
|
break;
|
||||||
case DatType.TruRip:
|
case DatType.TruRip:
|
||||||
@@ -328,7 +298,7 @@ namespace SabreTools
|
|||||||
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
_logger.Warning("The filename " + fileinfo[1].Value + " could not be mapped! Please check the mappings and try again");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GroupCollection truripInfo = Regex.Match(Remapping.TruRip[fileinfo[1].Value], _remappedPattern).Groups;
|
GroupCollection truripInfo = Regex.Match(Remapping.TruRip[fileinfo[1].Value], Constants.RemappedPattern).Groups;
|
||||||
|
|
||||||
manufacturer = truripInfo[1].Value;
|
manufacturer = truripInfo[1].Value;
|
||||||
system = truripInfo[2].Value;
|
system = truripInfo[2].Value;
|
||||||
@@ -342,7 +312,7 @@ namespace SabreTools
|
|||||||
source = fileinfo[3].Value;
|
source = fileinfo[3].Value;
|
||||||
datestring = fileinfo[4].Value;
|
datestring = fileinfo[4].Value;
|
||||||
|
|
||||||
GroupCollection cDateInfo = Regex.Match(datestring, _defaultDatePattern).Groups;
|
GroupCollection cDateInfo = Regex.Match(datestring, Constants.DefaultDatePattern).Groups;
|
||||||
date = cDateInfo[1].Value + "-" + cDateInfo[2].Value + "-" + cDateInfo[3].Value + " " +
|
date = cDateInfo[1].Value + "-" + cDateInfo[2].Value + "-" + cDateInfo[3].Value + " " +
|
||||||
cDateInfo[4].Value + ":" + cDateInfo[5].Value + ":" + cDateInfo[6].Value;
|
cDateInfo[4].Value + ":" + cDateInfo[5].Value + ":" + cDateInfo[6].Value;
|
||||||
break;
|
break;
|
||||||
@@ -504,7 +474,7 @@ namespace SabreTools
|
|||||||
slc2.ExecuteNonQuery();
|
slc2.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
query = "SELECT last_insert_rowid()";
|
query = "SELECT last_insertConstants.Rowid()";
|
||||||
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
gameid = (long)slc2.ExecuteScalar();
|
gameid = (long)slc2.ExecuteScalar();
|
||||||
@@ -569,7 +539,7 @@ SELECT files.id FROM files
|
|||||||
INSERT INTO files (setid, name, type, lastupdated)
|
INSERT INTO files (setid, name, type, lastupdated)
|
||||||
VALUES (" + gameid + ", '" + rom.Name.Replace("'", "''") + "', '" + rom.Type + "', '" + date + @"');
|
VALUES (" + gameid + ", '" + rom.Name.Replace("'", "''") + "', '" + rom.Type + "', '" + date + @"');
|
||||||
INSERT INTO checksums (file, size, crc, md5, sha1)
|
INSERT INTO checksums (file, size, crc, md5, sha1)
|
||||||
VALUES ((SELECT last_insert_rowid()), " + rom.Size + ", '" + rom.CRC + "'" + ", '" + rom.MD5 + "'" + ", '" + rom.SHA1 + @"');
|
VALUES ((SELECT last_insertConstants.Rowid()), " + rom.Size + ", '" + rom.CRC + "'" + ", '" + rom.MD5 + "'" + ", '" + rom.SHA1 + @"');
|
||||||
COMMIT;";
|
COMMIT;";
|
||||||
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
@@ -643,7 +613,7 @@ COMMIT;";
|
|||||||
slc2.ExecuteNonQuery();
|
slc2.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
query = "SELECT last_insert_rowid()";
|
query = "SELECT last_insertConstants.Rowid()";
|
||||||
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
hashid = (long)slc2.ExecuteScalar();
|
hashid = (long)slc2.ExecuteScalar();
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ namespace SabreTools
|
|||||||
public class TrimMerge
|
public class TrimMerge
|
||||||
{
|
{
|
||||||
// Instance variables
|
// Instance variables
|
||||||
private string _filename = "";
|
private string _filename;
|
||||||
private string _path = "";
|
private string _path;
|
||||||
private bool _rename;
|
private bool _rename;
|
||||||
private bool _forceunpack;
|
private bool _forceunpack;
|
||||||
private Logger _logger;
|
private Logger _logger;
|
||||||
|
|||||||
@@ -17,26 +17,6 @@ namespace SabreTools
|
|||||||
private Logger _logger;
|
private Logger _logger;
|
||||||
private bool _ignore;
|
private bool _ignore;
|
||||||
|
|
||||||
// Regex File Name Patterns
|
|
||||||
private static string _defaultPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.dat$";
|
|
||||||
private static string _defaultSpecialPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.xml$";
|
|
||||||
private static string _goodPattern = @"^(Good.*?)_.*\.dat";
|
|
||||||
private static string _goodXmlPattern = @"^(Good.*?)_.*\.xml";
|
|
||||||
private static string _mamePattern = @"^(.*)\.xml$";
|
|
||||||
private static string _maybeIntroPattern = @"(.*?) \[T-En\].*\((\d{8})\)\.dat$";
|
|
||||||
private static string _noIntroPattern = @"^(.*?) \((\d{8}-\d{6})_CM\)\.dat$";
|
|
||||||
private static string _noIntroNumberedPattern = @"(.*? - .*?) \(\d.*?_CM\).dat";
|
|
||||||
private static string _noIntroSpecialPattern = @"(.*? - .*?) \((\d{8})\)\.dat";
|
|
||||||
private static string _nonGoodPattern = @"^(NonGood.*?)( .*?)?.xml";
|
|
||||||
private static string _nonGoodSpecialPattern = @"^(NonGood.*?)( .*)?.dat";
|
|
||||||
private static string _redumpPattern = @"^(.*?) \((\d{8} \d{2}-\d{2}-\d{2})\)\.dat$";
|
|
||||||
private static string _redumpBiosPattern = @"^(.*?) \(\d+\) \((\d{4}-\d{2}-\d{2})\)\.dat$";
|
|
||||||
private static string _tosecPattern = @"^(.*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
|
||||||
private static string _tosecSpecialPatternA = @"^(.*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
|
||||||
private static string _tosecSpecialPatternB = @"^(.*? - .*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
|
||||||
private static string _truripPattern = @"^(.*) - .* \(trurip_XML\)\.dat$";
|
|
||||||
private static string _zandroPattern = @"^SMW-.*.xml";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize an Import object with the given information
|
/// Initialize an Import object with the given information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -108,7 +88,7 @@ namespace SabreTools
|
|||||||
string squery = @"BEGIN;
|
string squery = @"BEGIN;
|
||||||
INSERT INTO dats (size, sha1, name)
|
INSERT INTO dats (size, sha1, name)
|
||||||
VALUES (" + (new FileInfo(file)).Length + ", '" + hash + "', '" + file.Replace("'", "''") + @"');
|
VALUES (" + (new FileInfo(file)).Length + ", '" + hash + "', '" + file.Replace("'", "''") + @"');
|
||||||
SELECT last_insert_rowid();
|
SELECT last_insertConstants.Rowid();
|
||||||
COMMIT;";
|
COMMIT;";
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
{
|
{
|
||||||
@@ -189,7 +169,7 @@ COMMIT;";
|
|||||||
string tquery = @"BEGIN;
|
string tquery = @"BEGIN;
|
||||||
INSERT INTO source (name, url)
|
INSERT INTO source (name, url)
|
||||||
VALUES ('" + source + @"', '');
|
VALUES ('" + source + @"', '');
|
||||||
SELECT last_insert_rowid();
|
SELECT last_insertConstants.Rowid();
|
||||||
COMMIT;";
|
COMMIT;";
|
||||||
using (SqliteCommand sslc = new SqliteCommand(tquery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(tquery, dbc))
|
||||||
{
|
{
|
||||||
@@ -263,9 +243,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
// Determine which dattype we have
|
// Determine which dattype we have
|
||||||
GroupCollection fileinfo;
|
GroupCollection fileinfo;
|
||||||
|
|
||||||
if (Regex.IsMatch(filename, _nonGoodPattern))
|
if (Regex.IsMatch(filename, Constants.NonGoodPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _nonGoodPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NonGoodPattern).Groups;
|
||||||
if (!Remapping.NonGood.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.NonGood.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as NonGood but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as NonGood but could not be mapped.");
|
||||||
@@ -273,9 +253,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "NonGood";
|
source = "NonGood";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _nonGoodSpecialPattern))
|
else if (Regex.IsMatch(filename, Constants.NonGoodSpecialPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _nonGoodSpecialPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NonGoodSpecialPattern).Groups;
|
||||||
if (!Remapping.NonGood.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.NonGood.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as NonGood but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as NonGood but could not be mapped.");
|
||||||
@@ -283,9 +263,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "NonGood";
|
source = "NonGood";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _goodPattern))
|
else if (Regex.IsMatch(filename, Constants.GoodPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _goodPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.GoodPattern).Groups;
|
||||||
if (!Remapping.Good.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.Good.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Good but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Good but could not be mapped.");
|
||||||
@@ -293,13 +273,13 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "Good";
|
source = "Good";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _goodXmlPattern))
|
else if (Regex.IsMatch(filename, Constants.GoodXmlPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _goodXmlPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.GoodXmlPattern).Groups;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _maybeIntroPattern))
|
else if (Regex.IsMatch(filename, Constants.MaybeIntroPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _maybeIntroPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.MaybeIntroPattern).Groups;
|
||||||
if (!Remapping.MaybeIntro.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.MaybeIntro.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Maybe-Intro but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Maybe-Intro but could not be mapped.");
|
||||||
@@ -307,9 +287,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "Maybe-Intro";
|
source = "Maybe-Intro";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _noIntroPattern))
|
else if (Regex.IsMatch(filename, Constants.NoIntroPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _noIntroPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NoIntroPattern).Groups;
|
||||||
if (!Remapping.NoIntro.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.NoIntro.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as No-Intro but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as No-Intro but could not be mapped.");
|
||||||
@@ -318,9 +298,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
source = "no-Intro";
|
source = "no-Intro";
|
||||||
}
|
}
|
||||||
// For numbered DATs only
|
// For numbered DATs only
|
||||||
else if (Regex.IsMatch(filename, _noIntroNumberedPattern))
|
else if (Regex.IsMatch(filename, Constants.NoIntroNumberedPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _noIntroNumberedPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NoIntroNumberedPattern).Groups;
|
||||||
if (!Remapping.NoIntro.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.NoIntro.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as No-Intro but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as No-Intro but could not be mapped.");
|
||||||
@@ -329,9 +309,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
source = "no-Intro";
|
source = "no-Intro";
|
||||||
}
|
}
|
||||||
// For N-Gage and Gizmondo only
|
// For N-Gage and Gizmondo only
|
||||||
else if (Regex.IsMatch(filename, _noIntroSpecialPattern))
|
else if (Regex.IsMatch(filename, Constants.NoIntroSpecialPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _noIntroSpecialPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.NoIntroSpecialPattern).Groups;
|
||||||
if (!Remapping.NoIntro.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.NoIntro.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as No-Intro but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as No-Intro but could not be mapped.");
|
||||||
@@ -339,9 +319,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "no-Intro";
|
source = "no-Intro";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _redumpPattern))
|
else if (Regex.IsMatch(filename, Constants.RedumpPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _redumpPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.RedumpPattern).Groups;
|
||||||
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Redump but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Redump but could not be mapped.");
|
||||||
@@ -350,9 +330,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
source = "Redump";
|
source = "Redump";
|
||||||
}
|
}
|
||||||
// For special BIOSes only
|
// For special BIOSes only
|
||||||
else if (Regex.IsMatch(filename, _redumpBiosPattern))
|
else if (Regex.IsMatch(filename, Constants.RedumpBiosPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _redumpBiosPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.RedumpBiosPattern).Groups;
|
||||||
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.Redump.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Redump but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as Redump but could not be mapped.");
|
||||||
@@ -360,17 +340,17 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "Redump";
|
source = "Redump";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _tosecPattern))
|
else if (Regex.IsMatch(filename, Constants.TosecPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _tosecPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.TosecPattern).Groups;
|
||||||
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
// Handle special case mappings found only in TOSEC
|
// Handle special case mappings found only in TOSEC
|
||||||
fileinfo = Regex.Match(filename, _tosecSpecialPatternA).Groups;
|
fileinfo = Regex.Match(filename, Constants.TosecSpecialPatternA).Groups;
|
||||||
|
|
||||||
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _tosecSpecialPatternB).Groups;
|
fileinfo = Regex.Match(filename, Constants.TosecSpecialPatternB).Groups;
|
||||||
|
|
||||||
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TOSEC.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
@@ -381,9 +361,9 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "TOSEC";
|
source = "TOSEC";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _truripPattern))
|
else if (Regex.IsMatch(filename, Constants.TruripPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _truripPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.TruripPattern).Groups;
|
||||||
if (!Remapping.TruRip.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.TruRip.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as TruRip but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as TruRip but could not be mapped.");
|
||||||
@@ -391,23 +371,23 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
source = "trurip";
|
source = "trurip";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _zandroPattern))
|
else if (Regex.IsMatch(filename, Constants.ZandroPattern))
|
||||||
{
|
{
|
||||||
source = "Zandro";
|
source = "Zandro";
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _defaultPattern))
|
else if (Regex.IsMatch(filename, Constants.DefaultPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _defaultPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.DefaultPattern).Groups;
|
||||||
source = fileinfo[3].Value;
|
source = fileinfo[3].Value;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _defaultSpecialPattern))
|
else if (Regex.IsMatch(filename, Constants.DefaultSpecialPattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _defaultSpecialPattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.DefaultSpecialPattern).Groups;
|
||||||
source = fileinfo[3].Value;
|
source = fileinfo[3].Value;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(filename, _mamePattern))
|
else if (Regex.IsMatch(filename, Constants.MamePattern))
|
||||||
{
|
{
|
||||||
fileinfo = Regex.Match(filename, _mamePattern).Groups;
|
fileinfo = Regex.Match(filename, Constants.MamePattern).Groups;
|
||||||
if (!Remapping.MAME.ContainsKey(fileinfo[1].Value))
|
if (!Remapping.MAME.ContainsKey(fileinfo[1].Value))
|
||||||
{
|
{
|
||||||
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as MAME but could not be mapped.");
|
_logger.Warning("The filename " + fileinfo[1].Value + " was matched as MAME but could not be mapped.");
|
||||||
|
|||||||
@@ -317,10 +317,10 @@ namespace SabreTools
|
|||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
RomData rom = roms[i];
|
RomData rom = roms[i];
|
||||||
rom.Size = RomManipulation.SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = RomManipulation.CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = RomManipulation.MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = RomManipulation.SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
}
|
}
|
||||||
netNew[key] = temp;
|
netNew[key] = temp;
|
||||||
@@ -335,10 +335,10 @@ namespace SabreTools
|
|||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
RomData rom = roms[i];
|
RomData rom = roms[i];
|
||||||
rom.Size = RomManipulation.SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = RomManipulation.CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = RomManipulation.MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = RomManipulation.SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
}
|
}
|
||||||
unneeded[key] = temp;
|
unneeded[key] = temp;
|
||||||
@@ -353,10 +353,10 @@ namespace SabreTools
|
|||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
RomData rom = roms[i];
|
RomData rom = roms[i];
|
||||||
rom.Size = RomManipulation.SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = RomManipulation.CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = RomManipulation.MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = RomManipulation.SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
}
|
}
|
||||||
newMissing[key] = temp;
|
newMissing[key] = temp;
|
||||||
@@ -371,10 +371,10 @@ namespace SabreTools
|
|||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
RomData rom = roms[i];
|
RomData rom = roms[i];
|
||||||
rom.Size = RomManipulation.SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = RomManipulation.CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = RomManipulation.MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = RomManipulation.SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
}
|
}
|
||||||
have[key] = temp;
|
have[key] = temp;
|
||||||
@@ -485,10 +485,10 @@ namespace SabreTools
|
|||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
RomData rom = roms[i];
|
RomData rom = roms[i];
|
||||||
rom.Size = RomManipulation.SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = RomManipulation.CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = RomManipulation.MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = RomManipulation.SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
}
|
}
|
||||||
have[key] = temp;
|
have[key] = temp;
|
||||||
@@ -555,10 +555,10 @@ namespace SabreTools
|
|||||||
for (int i = 0; i < roms.Count; i++)
|
for (int i = 0; i < roms.Count; i++)
|
||||||
{
|
{
|
||||||
RomData rom = roms[i];
|
RomData rom = roms[i];
|
||||||
rom.Size = RomManipulation.SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = RomManipulation.CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = RomManipulation.MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = RomManipulation.SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
}
|
}
|
||||||
have[key] = temp;
|
have[key] = temp;
|
||||||
|
|||||||
@@ -7,14 +7,6 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
public class Build
|
public class Build
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The current toolset version to be used by all child applications
|
|
||||||
/// </summary>
|
|
||||||
public static string Version
|
|
||||||
{
|
|
||||||
get { return "0.7.5.0"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if running in a Mono environment
|
/// Returns true if running in a Mono environment
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -32,7 +24,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
// Dynamically create the header string
|
// Dynamically create the header string
|
||||||
string border = "+-----------------------------------------------------------------------------+";
|
string border = "+-----------------------------------------------------------------------------+";
|
||||||
string mid = name + " " + Build.Version;
|
string mid = name + " " + Constants.Version;
|
||||||
mid = "|" + mid.PadLeft(((77 - mid.Length) / 2) + mid.Length).PadRight(77) + "|";
|
mid = "|" + mid.PadLeft(((77 - mid.Length) / 2) + mid.Length).PadRight(77) + "|";
|
||||||
|
|
||||||
// Set the console to ready state
|
// Set the console to ready state
|
||||||
@@ -47,7 +39,7 @@ namespace SabreTools.Helper
|
|||||||
Console.BackgroundColor = ConsoleColor.Blue;
|
Console.BackgroundColor = ConsoleColor.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.Title = "SabreTools-" + name + " " + Build.Version;
|
Console.Title = "SabreTools-" + name + " " + Constants.Version;
|
||||||
|
|
||||||
// Output the header
|
// Output the header
|
||||||
Console.WriteLine(border);
|
Console.WriteLine(border);
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Converters
|
public class Converters
|
||||||
{
|
{
|
||||||
// Regex matching patterns
|
|
||||||
private static string _headerPatternCMP = @"(^.*?) \($";
|
|
||||||
private static string _itemPatternCMP = @"^\s*(\S*?) (.*)";
|
|
||||||
private static string _endPatternCMP = @"^\s*\)\s*$";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a ClrMamePro style DAT to an Logiqx XML derived DAT
|
/// Convert a ClrMamePro style DAT to an Logiqx XML derived DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,9 +35,9 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the line is the header or a game
|
// If the line is the header or a game
|
||||||
if (Regex.IsMatch(line, _headerPatternCMP))
|
if (Regex.IsMatch(line, Constants.HeaderPatternCMP))
|
||||||
{
|
{
|
||||||
GroupCollection gc = Regex.Match(line, _headerPatternCMP).Groups;
|
GroupCollection gc = Regex.Match(line, Constants.HeaderPatternCMP).Groups;
|
||||||
|
|
||||||
if (gc[1].Value == "clrmamepro" || gc[1].Value == "romvault")
|
if (gc[1].Value == "clrmamepro" || gc[1].Value == "romvault")
|
||||||
{
|
{
|
||||||
@@ -133,9 +128,9 @@ namespace SabreTools.Helper
|
|||||||
elem.Add(new XElement(temp));
|
elem.Add(new XElement(temp));
|
||||||
}
|
}
|
||||||
// If the line is anything but a rom or disk and we're in a block
|
// If the line is anything but a rom or disk and we're in a block
|
||||||
else if (Regex.IsMatch(line, _itemPatternCMP) && block)
|
else if (Regex.IsMatch(line, Constants.ItemPatternCMP) && block)
|
||||||
{
|
{
|
||||||
GroupCollection gc = Regex.Match(line, _itemPatternCMP).Groups;
|
GroupCollection gc = Regex.Match(line, Constants.ItemPatternCMP).Groups;
|
||||||
|
|
||||||
if (gc[1].Value == "name" && elem.Name != "header")
|
if (gc[1].Value == "name" && elem.Name != "header")
|
||||||
{
|
{
|
||||||
@@ -149,7 +144,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we find an end bracket that's not associated with anything else, the block is done
|
// If we find an end bracket that's not associated with anything else, the block is done
|
||||||
else if (Regex.IsMatch(line, _endPatternCMP) && block)
|
else if (Regex.IsMatch(line, Constants.EndPatternCMP) && block)
|
||||||
{
|
{
|
||||||
block = false;
|
block = false;
|
||||||
elem = elem.Parent;
|
elem = elem.Parent;
|
||||||
|
|||||||
51
SabreHelper/Data/Constants.cs
Normal file
51
SabreHelper/Data/Constants.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
namespace SabreTools.Helper
|
||||||
|
{
|
||||||
|
public class Constants
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The current toolset version to be used by all child applications
|
||||||
|
/// </summary>
|
||||||
|
public static string Version = "0.7.5.0";
|
||||||
|
|
||||||
|
// 0-byte file constants
|
||||||
|
public static long SizeZero = 0;
|
||||||
|
public static string CRCZero = "00000000";
|
||||||
|
public static string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
|
||||||
|
public static string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
||||||
|
|
||||||
|
// Regex File Name Patterns
|
||||||
|
public static string DefaultPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.dat$";
|
||||||
|
public static string DefaultSpecialPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.xml$";
|
||||||
|
public static string GoodPattern = @"^(Good.*?)_.*\.dat";
|
||||||
|
public static string GoodXmlPattern = @"^(Good.*?)_.*\.xml";
|
||||||
|
public static string MamePattern = @"^(.*)\.xml$";
|
||||||
|
public static string MaybeIntroPattern = @"(.*?) \[T-En\].*\((\d{8})\)\.dat$";
|
||||||
|
public static string NoIntroPattern = @"^(.*?) \((\d{8}-\d{6})_CM\)\.dat$";
|
||||||
|
public static string NoIntroNumberedPattern = @"(.*? - .*?) \(\d.*?_CM\).dat";
|
||||||
|
public static string NoIntroSpecialPattern = @"(.*? - .*?) \((\d{8})\)\.dat";
|
||||||
|
public static string NonGoodPattern = @"^(NonGood.*?)( .*?)?.xml";
|
||||||
|
public static string NonGoodSpecialPattern = @"^(NonGood.*?)( .*)?.dat";
|
||||||
|
public static string RedumpPattern = @"^(.*?) \((\d{8} \d{2}-\d{2}-\d{2})\)\.dat$";
|
||||||
|
public static string RedumpBiosPattern = @"^(.*?) \(\d+\) \((\d{4}-\d{2}-\d{2})\)\.dat$";
|
||||||
|
public static string TosecPattern = @"^(.*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
||||||
|
public static string TosecSpecialPatternA = @"^(.*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
||||||
|
public static string TosecSpecialPatternB = @"^(.*? - .*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\)\.dat$";
|
||||||
|
public static string TruripPattern = @"^(.*) - .* \(trurip_XML\)\.dat$";
|
||||||
|
public static string ZandroPattern = @"^SMW-.*.xml";
|
||||||
|
|
||||||
|
// Regex Mapped Name Patterns
|
||||||
|
public static string RemappedPattern = @"^(.*) - (.*)$";
|
||||||
|
|
||||||
|
// Regex Date Patterns
|
||||||
|
public static string DefaultDatePattern = @"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})";
|
||||||
|
public static string NoIntroDatePattern = @"(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})";
|
||||||
|
public static string NoIntroSpecialDatePattern = @"(\d{4})(\d{2})(\d{2})";
|
||||||
|
public static string RedumpDatePattern = @"(\d{4})(\d{2})(\d{2}) (\d{2})-(\d{2})-(\d{2})";
|
||||||
|
public static string TosecDatePattern = @"(\d{4})-(\d{2})-(\d{2})";
|
||||||
|
|
||||||
|
// Regex conversion patterns
|
||||||
|
public static string HeaderPatternCMP = @"(^.*?) \($";
|
||||||
|
public static string ItemPatternCMP = @"^\s*(\S*?) (.*)";
|
||||||
|
public static string EndPatternCMP = @"^\s*\)\s*$";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,12 +10,6 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
public class Output
|
public class Output
|
||||||
{
|
{
|
||||||
// 0-byte file constants
|
|
||||||
public static long SizeZero = 0;
|
|
||||||
public static string CRCZero = "00000000";
|
|
||||||
public static string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
|
|
||||||
public static string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create and open an output file for writing direct from a dictionary
|
/// Create and open an output file for writing direct from a dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -250,10 +244,10 @@ namespace SabreTools.Helper
|
|||||||
if (datdata.OutputFormat != OutputFormat.SabreDat && datdata.OutputFormat != OutputFormat.MissFile)
|
if (datdata.OutputFormat != OutputFormat.SabreDat && datdata.OutputFormat != OutputFormat.MissFile)
|
||||||
{
|
{
|
||||||
rom.Name = "-";
|
rom.Name = "-";
|
||||||
rom.Size = SizeZero;
|
rom.Size = Constants.SizeZero;
|
||||||
rom.CRC = CRCZero;
|
rom.CRC = Constants.CRCZero;
|
||||||
rom.MD5 = MD5Zero;
|
rom.MD5 = Constants.MD5Zero;
|
||||||
rom.SHA1 = SHA1Zero;
|
rom.SHA1 = Constants.SHA1Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, set the new path and such, write out, and continue
|
// Otherwise, set the new path and such, write out, and continue
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
public class RomManipulation
|
public class RomManipulation
|
||||||
{
|
{
|
||||||
// 0-byte file constants
|
|
||||||
public static long SizeZero = 0;
|
|
||||||
public static string CRCZero = "00000000";
|
|
||||||
public static string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
|
|
||||||
public static string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get what type of DAT the input file is
|
/// Get what type of DAT the input file is
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -504,12 +498,13 @@ namespace SabreTools.Helper
|
|||||||
sha1 = (sha1 == "" ? "" : sha1.PadLeft(40, '0'));
|
sha1 = (sha1 == "" ? "" : sha1.PadLeft(40, '0'));
|
||||||
|
|
||||||
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
||||||
if (subreader.Name == "rom" && (size == 0 || size == -1) && ((crc == CRCZero || crc == "") || md5 == MD5Zero || sha1 == SHA1Zero))
|
if (subreader.Name == "rom" && (size == 0 || size == -1) &&
|
||||||
|
((crc == Constants.CRCZero || crc == "") || md5 == Constants.MD5Zero || sha1 == Constants.SHA1Zero))
|
||||||
{
|
{
|
||||||
size = SizeZero;
|
size = Constants.SizeZero;
|
||||||
crc = CRCZero;
|
crc = Constants.CRCZero;
|
||||||
md5 = MD5Zero;
|
md5 = Constants.MD5Zero;
|
||||||
sha1 = SHA1Zero;
|
sha1 = Constants.SHA1Zero;
|
||||||
}
|
}
|
||||||
// If the file has no size and it's not the above case, skip and log
|
// If the file has no size and it's not the above case, skip and log
|
||||||
else if (subreader.Name == "rom" && (size == 0 || size == -1))
|
else if (subreader.Name == "rom" && (size == 0 || size == -1))
|
||||||
@@ -716,12 +711,12 @@ namespace SabreTools.Helper
|
|||||||
sha1 = (sha1 == "" ? "" : sha1.PadLeft(40, '0'));
|
sha1 = (sha1 == "" ? "" : sha1.PadLeft(40, '0'));
|
||||||
|
|
||||||
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
||||||
if (xtr.GetAttribute("type") == "rom" && (size == 0 || size == -1) && ((crc == CRCZero || crc == "") || md5 == MD5Zero || sha1 == SHA1Zero))
|
if (xtr.GetAttribute("type") == "rom" && (size == 0 || size == -1) && ((crc == Constants.CRCZero || crc == "") || md5 == Constants.MD5Zero || sha1 == Constants.SHA1Zero))
|
||||||
{
|
{
|
||||||
size = SizeZero;
|
size = Constants.SizeZero;
|
||||||
crc = CRCZero;
|
crc = Constants.CRCZero;
|
||||||
md5 = MD5Zero;
|
md5 = Constants.MD5Zero;
|
||||||
sha1 = SHA1Zero;
|
sha1 = Constants.SHA1Zero;
|
||||||
}
|
}
|
||||||
// If the file has no size and it's not the above case, skip and log
|
// If the file has no size and it's not the above case, skip and log
|
||||||
else if (xtr.GetAttribute("type") == "rom" && (size == 0 || size == -1))
|
else if (xtr.GetAttribute("type") == "rom" && (size == 0 || size == -1))
|
||||||
|
|||||||
@@ -90,16 +90,17 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Data\Constants.cs" />
|
||||||
<Compile Include="Converters.cs" />
|
<Compile Include="Converters.cs" />
|
||||||
<Compile Include="CRC32.cs" />
|
<Compile Include="CRC32.cs" />
|
||||||
<Compile Include="DBTools.cs" />
|
<Compile Include="DBTools.cs" />
|
||||||
<Compile Include="Enums.cs" />
|
<Compile Include="Data\Enums.cs" />
|
||||||
<Compile Include="Logger.cs" />
|
<Compile Include="Logger.cs" />
|
||||||
<Compile Include="Output.cs" />
|
<Compile Include="Output.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Remapping.cs" />
|
<Compile Include="Remapping.cs" />
|
||||||
<Compile Include="RomManipulation.cs" />
|
<Compile Include="RomManipulation.cs" />
|
||||||
<Compile Include="Structs.cs" />
|
<Compile Include="Data\Structs.cs" />
|
||||||
<Compile Include="Style.cs" />
|
<Compile Include="Style.cs" />
|
||||||
<Compile Include="Build.cs" />
|
<Compile Include="Build.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user