mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Support all framework versions
This commit is contained in:
@@ -436,7 +436,7 @@ namespace SabreTools.DatFiles
|
||||
#region .csv
|
||||
|
||||
// CSV
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.CSV) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.CSV))
|
||||
@@ -451,7 +451,7 @@ namespace SabreTools.DatFiles
|
||||
#region .dat
|
||||
|
||||
// ClrMamePro
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.ClrMamePro) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.ClrMamePro))
|
||||
@@ -462,7 +462,7 @@ namespace SabreTools.DatFiles
|
||||
};
|
||||
|
||||
// RomCenter
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RomCenter) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RomCenter))
|
||||
@@ -481,7 +481,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// DOSCenter
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.DOSCenter) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.DOSCenter))
|
||||
@@ -504,7 +504,7 @@ namespace SabreTools.DatFiles
|
||||
#region .json
|
||||
|
||||
// JSON
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.SabreJSON) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.SabreJSON))
|
||||
@@ -519,7 +519,7 @@ namespace SabreTools.DatFiles
|
||||
#region .md5
|
||||
|
||||
// Redump MD5
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpMD5) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpMD5))
|
||||
@@ -534,7 +534,7 @@ namespace SabreTools.DatFiles
|
||||
#region .sfv
|
||||
|
||||
// Redump SFV
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpSFV) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpSFV))
|
||||
@@ -549,7 +549,7 @@ namespace SabreTools.DatFiles
|
||||
#region .sha1
|
||||
|
||||
// Redump SHA-1
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpSHA1) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpSHA1))
|
||||
@@ -564,7 +564,7 @@ namespace SabreTools.DatFiles
|
||||
#region .sha256
|
||||
|
||||
// Redump SHA-256
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpSHA256) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpSHA256))
|
||||
@@ -579,7 +579,7 @@ namespace SabreTools.DatFiles
|
||||
#region .sha384
|
||||
|
||||
// Redump SHA-384
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpSHA384) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpSHA384))
|
||||
@@ -594,7 +594,7 @@ namespace SabreTools.DatFiles
|
||||
#region .sha512
|
||||
|
||||
// Redump SHA-512
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpSHA512) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpSHA512))
|
||||
@@ -609,7 +609,7 @@ namespace SabreTools.DatFiles
|
||||
#region .spamsum
|
||||
|
||||
// Redump SpamSum
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.RedumpSpamSum) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.RedumpSpamSum))
|
||||
@@ -624,7 +624,7 @@ namespace SabreTools.DatFiles
|
||||
#region .ssv
|
||||
|
||||
// SSV
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.SSV) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.SSV))
|
||||
@@ -639,7 +639,7 @@ namespace SabreTools.DatFiles
|
||||
#region .tsv
|
||||
|
||||
// TSV
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.TSV) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.TSV))
|
||||
@@ -654,7 +654,7 @@ namespace SabreTools.DatFiles
|
||||
#region .txt
|
||||
|
||||
// AttractMode
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.AttractMode) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.AttractMode))
|
||||
@@ -665,7 +665,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// MAME Listroms
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.Listrom) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.Listrom))
|
||||
@@ -684,7 +684,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Missfile
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.MissFile) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.MissFile))
|
||||
@@ -703,7 +703,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Everdrive SMDB
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.EverdriveSMDB) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.EverdriveSMDB))
|
||||
@@ -726,7 +726,7 @@ namespace SabreTools.DatFiles
|
||||
#region .xml
|
||||
|
||||
// Logiqx XML
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.Logiqx) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.Logiqx))
|
||||
@@ -735,7 +735,7 @@ namespace SabreTools.DatFiles
|
||||
outfileNames.Add(DatFormat.Logiqx, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
||||
usedExtensions.Add(".xml");
|
||||
}
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.LogiqxDeprecated) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.LogiqxDeprecated))
|
||||
@@ -746,7 +746,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// SabreDAT
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.SabreXML) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.SabreXML))
|
||||
@@ -765,7 +765,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Software List
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.SoftwareList) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.SoftwareList))
|
||||
@@ -784,7 +784,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// MAME Listxml
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.Listxml) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.Listxml))
|
||||
@@ -803,7 +803,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// OfflineList
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.OfflineList) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.OfflineList))
|
||||
@@ -822,7 +822,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// openMSX
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.OpenMSX) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.OpenMSX))
|
||||
@@ -841,7 +841,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Archive.org
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datFormat & DatFormat.ArchiveDotOrg) != 0)
|
||||
#else
|
||||
if (datFormat.HasFlag(DatFormat.ArchiveDotOrg))
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace SabreTools.DatItems
|
||||
return output;
|
||||
|
||||
// If the duplicate is external already or should be, set it
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((lastItem.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.External) != 0
|
||||
|| lastItem?.GetFieldValue<Source?>(DatItem.SourceKey)?.Index != GetFieldValue<Source?>(DatItem.SourceKey)?.Index)
|
||||
#else
|
||||
@@ -283,7 +283,7 @@ namespace SabreTools.DatItems
|
||||
return output;
|
||||
|
||||
// If the duplicate is external already or should be, set it
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((lastItem.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.External) != 0
|
||||
|| lastSource?.Index != source?.Index)
|
||||
#else
|
||||
@@ -668,7 +668,7 @@ namespace SabreTools.DatItems
|
||||
?? string.Empty;
|
||||
|
||||
// If the current item exactly matches the last item, then we don't add it
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datItem.GetDuplicateStatus(lastItem) & DupeType.All) != 0)
|
||||
#else
|
||||
if (datItem.GetDuplicateStatus(lastItem).HasFlag(DupeType.All))
|
||||
@@ -763,7 +763,7 @@ namespace SabreTools.DatItems
|
||||
?? string.Empty;
|
||||
|
||||
// If the current item exactly matches the last item, then we don't add it
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((datItem.Value.GetDuplicateStatus(lastItem) & DupeType.All) != 0)
|
||||
#else
|
||||
if (datItem.Value.GetDuplicateStatus(lastItem).HasFlag(DupeType.All))
|
||||
|
||||
@@ -590,7 +590,7 @@ namespace SabreTools.DatTools
|
||||
// Loop through and add the items correctly
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.External) != 0)
|
||||
#else
|
||||
if (item.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.External))
|
||||
@@ -686,7 +686,7 @@ namespace SabreTools.DatTools
|
||||
long sourceIndex = itemSourceMappings[item.Key];
|
||||
|
||||
// If the current item isn't an external duplicate
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.External) == 0)
|
||||
#else
|
||||
if (!item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.External))
|
||||
@@ -818,7 +818,7 @@ namespace SabreTools.DatTools
|
||||
if (item.GetFieldValue<Source?>(DatItem.SourceKey) == null)
|
||||
continue;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.Internal) != 0 || item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
||||
#else
|
||||
if (item.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.Internal) || item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
||||
@@ -944,7 +944,7 @@ namespace SabreTools.DatTools
|
||||
continue;
|
||||
#endif
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.Internal) != 0 || item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
||||
#else
|
||||
if (item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.Internal) || item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
||||
@@ -1025,7 +1025,7 @@ namespace SabreTools.DatTools
|
||||
// Loop through and add the items correctly
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.Internal) != 0 || item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
||||
#else
|
||||
if (item.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.Internal) || item.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
||||
@@ -1119,7 +1119,7 @@ namespace SabreTools.DatTools
|
||||
long sourceIndex = itemSourceMappings[item.Key];
|
||||
|
||||
// If the current item isn't a duplicate
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.Internal) == 0 && item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) != 0x00)
|
||||
#else
|
||||
if (!item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.Internal) && item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) != 0x00)
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace SabreTools.DatTools
|
||||
archive.AvailableHashTypes = _hashes;
|
||||
|
||||
// Skip if we're treating archives as files and skipping files
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((asFiles & TreatAsFile.Archive) != 0 && _skipFileType == SkipFileType.File)
|
||||
#else
|
||||
if (asFiles.HasFlag(TreatAsFile.Archive) && _skipFileType == SkipFileType.File)
|
||||
@@ -172,7 +172,7 @@ namespace SabreTools.DatTools
|
||||
}
|
||||
|
||||
// Process as archive if we're not treating archives as files
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
else if ((asFiles & TreatAsFile.Archive) == 0)
|
||||
#else
|
||||
else if (!asFiles.HasFlag(TreatAsFile.Archive))
|
||||
|
||||
@@ -329,13 +329,13 @@ namespace SabreTools.DatTools
|
||||
DatItem? internalDatItem;
|
||||
if (internalFileInfo == null)
|
||||
internalDatItem = null;
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
else if (internalFileInfo is FileTypes.Aaru.AaruFormat && (asFiles & TreatAsFile.AaruFormat) == 0)
|
||||
#else
|
||||
else if (internalFileInfo is FileTypes.Aaru.AaruFormat && !asFiles.HasFlag(TreatAsFile.AaruFormat))
|
||||
#endif
|
||||
internalDatItem = new Media(internalFileInfo);
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
else if (internalFileInfo is FileTypes.CHD.CHDFile && (asFiles & TreatAsFile.CHD) == 0)
|
||||
#else
|
||||
else if (internalFileInfo is FileTypes.CHD.CHDFile && !asFiles.HasFlag(TreatAsFile.CHD))
|
||||
|
||||
@@ -222,35 +222,35 @@ namespace SabreTools.DatTools
|
||||
// For each output format, get the appropriate stream writer
|
||||
output.Add(StatReportFormat.None, CreateOutStatsNamesHelper(outDir, ".null", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((statDatFormat & StatReportFormat.Textfile) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.Textfile))
|
||||
#endif
|
||||
output.Add(StatReportFormat.Textfile, CreateOutStatsNamesHelper(outDir, ".txt", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((statDatFormat & StatReportFormat.CSV) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.CSV))
|
||||
#endif
|
||||
output.Add(StatReportFormat.CSV, CreateOutStatsNamesHelper(outDir, ".csv", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((statDatFormat & StatReportFormat.HTML) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.HTML))
|
||||
#endif
|
||||
output.Add(StatReportFormat.HTML, CreateOutStatsNamesHelper(outDir, ".html", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((statDatFormat & StatReportFormat.SSV) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.SSV))
|
||||
#endif
|
||||
output.Add(StatReportFormat.SSV, CreateOutStatsNamesHelper(outDir, ".ssv", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if ((statDatFormat & StatReportFormat.TSV) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.TSV))
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace SabreTools.FileTypes
|
||||
|
||||
// Get the info in the proper manner
|
||||
BaseFile? baseFile;
|
||||
#if NETFRAMEWORK
|
||||
#if NET20 || NET35
|
||||
if (fileType == FileType.AaruFormat && (asFiles & TreatAsFile.AaruFormat) == 0)
|
||||
baseFile = AaruFormat.Create(inputStream);
|
||||
else if (fileType == FileType.CHD && (asFiles & TreatAsFile.CHD) == 0)
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>
|
||||
net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
||||
@@ -91,7 +91,7 @@ Reset the internal state: reset();";
|
||||
foreach (string line in lines)
|
||||
{
|
||||
// Skip empty lines
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
if (string.IsNullOrEmpty(line))
|
||||
continue;
|
||||
|
||||
// Skip lines that start with REM or #
|
||||
@@ -473,7 +473,7 @@ Reset the internal state: reset();";
|
||||
// If we had any unmapped formats, return an issue
|
||||
if (unmappedFormats.Count > 0)
|
||||
{
|
||||
string message = $"The following inputs were invalid formats: {string.Join(", ", unmappedFormats)}";
|
||||
string message = $"The following inputs were invalid formats: {string.Join(", ", [.. unmappedFormats])}";
|
||||
return (false, message);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,11 @@ namespace SabreTools.Features
|
||||
OutputDir = file.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||
|
||||
// Extension splitting
|
||||
#if NET20 || NET35
|
||||
if ((splittingMode & SplittingMode.Extension) != 0)
|
||||
#else
|
||||
if (splittingMode.HasFlag(SplittingMode.Extension))
|
||||
#endif
|
||||
{
|
||||
(DatFile? extADat, DatFile? extBDat) = DatTools.Splitter.SplitByExtension(internalDat, GetList(features, ExtAListValue), GetList(features, ExtBListValue));
|
||||
//(DatFile? extADat, DatFile? extBDat) = DatTools.Splitter.SplitByExtensionDB(internalDat, GetList(features, ExtAListValue), GetList(features, ExtBListValue));
|
||||
@@ -89,7 +93,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Hash splitting
|
||||
#if NET20 || NET35
|
||||
if ((splittingMode & SplittingMode.Hash) != 0)
|
||||
#else
|
||||
if (splittingMode.HasFlag(SplittingMode.Hash))
|
||||
#endif
|
||||
{
|
||||
Dictionary<string, DatFile> typeDats = DatTools.Splitter.SplitByHash(internalDat);
|
||||
//Dictionary<string, DatFile> typeDats = DatTools.Splitter.SplitByHashDB(internalDat);
|
||||
@@ -116,7 +124,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Level splitting
|
||||
#if NET20 || NET35
|
||||
if ((splittingMode & SplittingMode.Level) != 0)
|
||||
#else
|
||||
if (splittingMode.HasFlag(SplittingMode.Level))
|
||||
#endif
|
||||
{
|
||||
logger.Warning("This feature is not implemented: level-split");
|
||||
DatTools.Splitter.SplitByLevel(
|
||||
@@ -127,7 +139,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Size splitting
|
||||
#if NET20 || NET35
|
||||
if ((splittingMode & SplittingMode.Size) != 0)
|
||||
#else
|
||||
if (splittingMode.HasFlag(SplittingMode.Size))
|
||||
#endif
|
||||
{
|
||||
(DatFile lessThan, DatFile greaterThan) = DatTools.Splitter.SplitBySize(internalDat, GetInt64(features, RadixInt64Value));
|
||||
//(DatFile lessThan, DatFile greaterThan) = DatTools.Splitter.SplitBySizeDB(internalDat, GetInt64(features, RadixInt64Value));
|
||||
@@ -142,7 +158,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Total Size splitting
|
||||
#if NET20 || NET35
|
||||
if ((splittingMode & SplittingMode.TotalSize) != 0)
|
||||
#else
|
||||
if (splittingMode.HasFlag(SplittingMode.TotalSize))
|
||||
#endif
|
||||
{
|
||||
logger.Warning("This feature is not implemented: level-split");
|
||||
List<DatFile> sizedDats = DatTools.Splitter.SplitByTotalSize(internalDat, GetInt64(features, ChunkSizeInt64Value));
|
||||
@@ -169,7 +189,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Type splitting
|
||||
#if NET20 || NET35
|
||||
if ((splittingMode & SplittingMode.Type) != 0)
|
||||
#else
|
||||
if (splittingMode.HasFlag(SplittingMode.Type))
|
||||
#endif
|
||||
{
|
||||
Dictionary<ItemType, DatFile> typeDats = DatTools.Splitter.SplitByType(internalDat);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ The stats that are outputted are as follows:
|
||||
string filename = Header!.GetStringFieldValue(DatFiles.DatHeader.FileNameKey)!;
|
||||
if (Path.GetFileName(filename) != filename)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(OutputDir))
|
||||
if (string.IsNullOrEmpty(OutputDir))
|
||||
OutputDir = Path.GetDirectoryName(filename);
|
||||
else
|
||||
OutputDir = Path.Combine(OutputDir, Path.GetDirectoryName(filename)!);
|
||||
|
||||
@@ -95,29 +95,33 @@ namespace SabreTools.Features
|
||||
var updateMode = GetUpdateMode(features);
|
||||
|
||||
// Normalize the extensions
|
||||
Header!.SetFieldValue<string?>(DatHeader.AddExtensionKey, (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(DatHeader.AddExtensionKey)) || Header.GetStringFieldValue(DatHeader.AddExtensionKey)!.StartsWith(".")
|
||||
Header!.SetFieldValue<string?>(DatHeader.AddExtensionKey, (string.IsNullOrEmpty(Header.GetStringFieldValue(DatHeader.AddExtensionKey)) || Header.GetStringFieldValue(DatHeader.AddExtensionKey)!.StartsWith(".")
|
||||
? Header.GetStringFieldValue(DatHeader.AddExtensionKey)
|
||||
: $".{Header.GetStringFieldValue(DatHeader.AddExtensionKey)}"));
|
||||
Header.SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(DatHeader.ReplaceExtensionKey)) || Header.GetStringFieldValue(DatHeader.ReplaceExtensionKey)!.StartsWith(".")
|
||||
Header.SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, (string.IsNullOrEmpty(Header.GetStringFieldValue(DatHeader.ReplaceExtensionKey)) || Header.GetStringFieldValue(DatHeader.ReplaceExtensionKey)!.StartsWith(".")
|
||||
? Header.GetStringFieldValue(DatHeader.ReplaceExtensionKey)
|
||||
: $".{Header.GetStringFieldValue(DatHeader.ReplaceExtensionKey)}"));
|
||||
|
||||
// If we're in a non-replacement special update mode and the names aren't set, set defaults
|
||||
if (updateMode != 0
|
||||
#if NET20 || NET35
|
||||
&& !(((updateMode & UpdateMode.DiffAgainst) != 0) || ((updateMode & UpdateMode.BaseReplace) != 0)))
|
||||
#else
|
||||
&& !(updateMode.HasFlag(UpdateMode.DiffAgainst) || updateMode.HasFlag(UpdateMode.BaseReplace)))
|
||||
#endif
|
||||
{
|
||||
// Get the values that will be used
|
||||
if (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(Models.Metadata.Header.DateKey)))
|
||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.DateKey)))
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.DateKey, DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(Models.Metadata.Header.NameKey)))
|
||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.NameKey)))
|
||||
{
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.NameKey, (updateMode != 0 ? "DiffDAT" : "MergeDAT")
|
||||
+ (Header.GetStringFieldValue(Models.Metadata.Header.TypeKey) == "SuperDAT" ? "-SuperDAT" : string.Empty)
|
||||
+ (Cleaner!.DedupeRoms != DedupeType.None ? "-deduped" : string.Empty));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(Models.Metadata.Header.DescriptionKey)))
|
||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.DescriptionKey)))
|
||||
{
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.DescriptionKey, (updateMode != 0 ? "DiffDAT" : "MergeDAT")
|
||||
+ (Header.GetStringFieldValue(Models.Metadata.Header.TypeKey) == "SuperDAT" ? "-SuperDAT" : string.Empty)
|
||||
@@ -127,13 +131,13 @@ namespace SabreTools.Features
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.DescriptionKey, $"{Header.GetStringFieldValue(Models.Metadata.Header.DescriptionKey)} ({Header.GetStringFieldValue(Models.Metadata.Header.DateKey)})");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(Models.Metadata.Header.CategoryKey)) && updateMode != 0)
|
||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.CategoryKey)) && updateMode != 0)
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.CategoryKey, "DiffDAT");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(Models.Metadata.Header.AuthorKey)))
|
||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.AuthorKey)))
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.AuthorKey, $"SabreTools {Globals.Version}");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Header.GetStringFieldValue(Models.Metadata.Header.CommentKey)))
|
||||
if (string.IsNullOrEmpty(Header.GetStringFieldValue(Models.Metadata.Header.CommentKey)))
|
||||
Header.SetFieldValue<string?>(Models.Metadata.Header.CommentKey, $"Generated by SabreTools {Globals.Version}");
|
||||
}
|
||||
|
||||
@@ -169,9 +173,15 @@ namespace SabreTools.Features
|
||||
|
||||
// Check the current format
|
||||
DatFormat currentFormat = datFile.Header.GetFieldValue<DatFormat>(DatHeader.DatFormatKey);
|
||||
#if NET20 || NET35
|
||||
bool isSeparatedFile = (currentFormat & DatFormat.CSV) != 0
|
||||
|| (currentFormat & DatFormat.SSV) != 0
|
||||
|| (currentFormat & DatFormat.TSV) != 0;
|
||||
#else
|
||||
bool isSeparatedFile = currentFormat.HasFlag(DatFormat.CSV)
|
||||
|| currentFormat.HasFlag(DatFormat.SSV)
|
||||
|| currentFormat.HasFlag(DatFormat.TSV);
|
||||
#endif
|
||||
|
||||
Parser.ParseInto(datFile, inputPath, keep: true, keepext: isSeparatedFile);
|
||||
|
||||
@@ -198,12 +208,20 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Reverse inputs if we're in a required mode
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffReverseCascade) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffReverseCascade))
|
||||
#endif
|
||||
{
|
||||
updateMode |= UpdateMode.DiffCascade;
|
||||
inputPaths.Reverse();
|
||||
}
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.ReverseBaseReplace) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.ReverseBaseReplace))
|
||||
#endif
|
||||
{
|
||||
updateMode |= UpdateMode.BaseReplace;
|
||||
basePaths.Reverse();
|
||||
@@ -214,7 +232,11 @@ namespace SabreTools.Features
|
||||
|
||||
// Populate using the correct set
|
||||
List<DatHeader> datHeaders;
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffAgainst) != 0 || (updateMode & UpdateMode.BaseReplace) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffAgainst) || updateMode.HasFlag(UpdateMode.BaseReplace))
|
||||
#endif
|
||||
datHeaders = DatFileTool.PopulateUserData(userInputDat, basePaths);
|
||||
else
|
||||
datHeaders = DatFileTool.PopulateUserData(userInputDat, inputPaths);
|
||||
@@ -228,7 +250,11 @@ namespace SabreTools.Features
|
||||
Remover!.ApplyRemovals(userInputDat);
|
||||
|
||||
// Output only DatItems that are duplicated across inputs
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffDupesOnly) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffDupesOnly))
|
||||
#endif
|
||||
{
|
||||
DatFile dupeData = DatFileTool.DiffDuplicates(userInputDat, inputPaths);
|
||||
//DatFile dupeData = DatFileTool.DiffDuplicatesDB(userInputDat, inputPaths);
|
||||
@@ -239,7 +265,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Output only DatItems that are not duplicated across inputs
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffNoDupesOnly) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffNoDupesOnly))
|
||||
#endif
|
||||
{
|
||||
DatFile outerDiffData = DatFileTool.DiffNoDuplicates(userInputDat, inputPaths);
|
||||
//DatFile outerDiffData = DatFileTool.DiffNoDuplicatesDB(userInputDat, inputPaths);
|
||||
@@ -250,7 +280,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Output only DatItems that are unique to each input
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffIndividualsOnly) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffIndividualsOnly))
|
||||
#endif
|
||||
{
|
||||
// Get all of the output DatFiles
|
||||
List<DatFile> datFiles = DatFileTool.DiffIndividuals(userInputDat, inputPaths);
|
||||
@@ -281,7 +315,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Output cascaded diffs
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffCascade) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffCascade))
|
||||
#endif
|
||||
{
|
||||
// Preprocess the DatHeaders
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
@@ -337,7 +375,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Output differences against a base DAT
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.DiffAgainst) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.DiffAgainst))
|
||||
#endif
|
||||
{
|
||||
// Loop through each input and diff against the base
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
@@ -374,7 +416,11 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Output DATs after replacing fields from a base DatFile
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.BaseReplace) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.BaseReplace))
|
||||
#endif
|
||||
{
|
||||
// Loop through each input and apply the base DatFile
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
@@ -418,7 +464,11 @@ namespace SabreTools.Features
|
||||
|
||||
// Merge all input files and write
|
||||
// This has to be last due to the SuperDAT handling
|
||||
#if NET20 || NET35
|
||||
if ((updateMode & UpdateMode.Merge) != 0)
|
||||
#else
|
||||
if (updateMode.HasFlag(UpdateMode.Merge))
|
||||
#endif
|
||||
{
|
||||
// If we're in SuperDAT mode, prefix all games with their respective DATs
|
||||
if (string.Equals(userInputDat.Header.GetStringFieldValue(Models.Metadata.Header.TypeKey), "SuperDAT", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
@@ -33,14 +33,18 @@ namespace SabreTools
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Perform initial setup and verification
|
||||
#if NET20 || NET35
|
||||
LoggerImpl.SetFilename(Path.Combine(Path.Combine(PathTool.GetRuntimeDirectory(), "logs"), "sabretools.log"), true);
|
||||
#else
|
||||
LoggerImpl.SetFilename(Path.Combine(PathTool.GetRuntimeDirectory(), "logs", "sabretools.log"), true);
|
||||
#endif
|
||||
LoggerImpl.AppendPrefix = true;
|
||||
LoggerImpl.LowestLogLevel = LogLevel.VERBOSE;
|
||||
LoggerImpl.ThrowOnError = false;
|
||||
LoggerImpl.Start();
|
||||
|
||||
// Reformat the arguments, if needed
|
||||
if (Array.Exists(args, a => a.Contains('"')))
|
||||
if (Array.Exists(args, a => a.Contains("\"")))
|
||||
args = ReformatArguments(args);
|
||||
|
||||
// Create a new Help object for this program
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<OutputType>Exe</OutputType>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||
|
||||
@@ -54,7 +54,7 @@ RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "o
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if [ $USE_ALL = true ]; then
|
||||
FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0") # TODO: Support all frameworks
|
||||
FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
|
||||
fi
|
||||
|
||||
# Create the filter arrays
|
||||
|
||||
@@ -45,7 +45,7 @@ $RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'os
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if ($USE_ALL.IsPresent) {
|
||||
$FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0') # TODO: Support all frameworks
|
||||
$FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
|
||||
}
|
||||
|
||||
# Create the filter arrays
|
||||
|
||||
Reference in New Issue
Block a user