diff --git a/.gitignore b/.gitignore index 7349e69f..59210b80 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,6 @@ /Deheader/obj /Deheader/obj/Debug /Deheader/obj/Release -/OfflineMerge/obj -/OfflineMerge/obj/Debug -/OfflineMerge/obj/Release /SabreTools/obj /SabreTools/obj/Debug /SabreTools/obj/Release diff --git a/OfflineMerge/App.config b/OfflineMerge/App.config deleted file mode 100644 index 88fa4027..00000000 --- a/OfflineMerge/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OfflineMerge/OfflineMerge.csproj b/OfflineMerge/OfflineMerge.csproj deleted file mode 100644 index 46af5009..00000000 --- a/OfflineMerge/OfflineMerge.csproj +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Debug - AnyCPU - {88310DB9-3B64-4268-AD48-2E0358D4CA5F} - Exe - Properties - OfflineMerge - OfflineMerge - v4.5.2 - 512 - true - - - AnyCPU - true - full - false - ..\..\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - ..\..\Release\ - TRACE - prompt - 4 - - - true - ..\..\Debug-x64\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - true - - - ..\..\Release-x64\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - true - - - - - - - - - - - - - - - - - - - - - {225a1afd-0890-44e8-b779-7502665c23a5} - SabreTools.Helper - - - - - \ No newline at end of file diff --git a/OfflineMerge/Properties/AssemblyInfo.cs b/OfflineMerge/Properties/AssemblyInfo.cs deleted file mode 100644 index 7a77ff03..00000000 --- a/OfflineMerge/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OfflineMerge")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OfflineMerge")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("88310db9-3b64-4268-ad48-2e0358d4ca5f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index 4c02b17e..cf946a73 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -68,18 +68,18 @@ namespace SabreTools.Helper switch (className) { - case "DATabase": + case "SabreTools": Console.Write(@" -DATabase - Import and Generate DAT files +SabreTools - Import, generate, manipulate DAT files ----------------------------------------- -Usage: DATabase [option] [filename|dirname] ... +Usage: SabreTools [option] [filename|dirname] ... Options: -?, -h, --help Show this help -a, --add Add a new system or source to the database -manu= Manufacturer name (system only) - -system= System name (system only) - -source= Source name (source only) + -system= System name (system only) + -source= Source name (source only) -url= URL (source only) -d, --dfd Enable Dir2DAT mode -nm, --noMD5 Don't include MD5 in output @@ -88,22 +88,22 @@ Options: -u, --unzip Force unzipping in created DAT -f, --files Treat archives as files -o, --old Output DAT in CMP format instead of XML - -gz, --gz-files Allow reading of GZIP files as archives + -gz, --gz-files Allow reading of GZIP files as archives -ro, --romba Read files from a Romba input -f=, --filename= Set the external name of the DAT -n=, --name= Set the internal name of the DAT -d=, --desc= Set the description of the DAT -c=, --cat= Set the category of the DAT - -v=, --version= Set the version of the DAT - -au=, --author= Set the author of the DAT - -sd, --superdat Enable SuperDAT creation + -v=, --version= Set the version of the DAT + -au=, --author= Set the author of the DAT + -sd, --superdat Enable SuperDAT creation -t=, --temp= Set the temporary directory to use - -es, --ext-split Split a DAT by two file extensions + -es, --ext-split Split a DAT by two file extensions -exta= First set of extensions (comma-separated) -extb= Second set of extensions (comma-separated) -out= Output directory -g, --generate Start tool in generate mode - -system= System ID to generate from + -system= System ID to generate from -nr, --no-rename Don't auto-rename games -o, --old Output DAT in CMP format instead of XML -ga, --generate-all Start tool in generate all mode @@ -118,7 +118,7 @@ Options: -m, --merge Merge one or more DATs -di, --diff Output all diffdats (merge flag not required) -c, --cascade Enable cascaded diffing - -ip, --inplace Enable inplace, cascaded diffing + -ip, --inplace Enable inplace, cascaded diff -dd, --dedup Enable deduping in the created DAT -b, --bare Don't include date in file name -u, --unzip Force unzipping in created DAT @@ -131,6 +131,11 @@ Options: -ca=, --category= Set the category of the DAT -v=, --version= Set the version of the DAT -au=, --author= Set the author of the DAT + -ol, --offmerge Update DATS for offline arrays (see notes) + -com= Complete current DAT + -fix= Complete current Missing + -new= New Complete DAT + -fk, --fake Replace all hashes and sizes by the default -rm, --remove Remove a system or source from the database -system= System ID -source= Source ID @@ -144,9 +149,9 @@ Options: -oc, --output-cmp Output in CMP format -om, --output-miss Output in Missfile format -r, --roms Output roms to miss instead of sets - -gp, --game-prefix Add game name as a prefix to each item + -gp, --game-prefix Add game name as a prefix -pre=, --prefix= Set prefix for all lines - -post=, --postfix= Set postfix for all lines + -post=, --postfix= Set postfix for all lines -q, --quotes Put double-quotes around each item -ae=, --add-ext= Add an extension to each item -re=, --rep-ext= Replace all extensions with specified @@ -170,13 +175,13 @@ Options: -sd=, --superdat Set SuperDAT type -fm=, --forcemerge= Set force merging Supported values are: - None, Split, Full + None, Split, Full -fn=, --forcend= Set force nodump Supported values are: - None, Obsolete, Required, Ignore + None, Obsolete, Required, Ignore -fp=, --forcepack= Set force packing Supported values are: - None, Zip, Unzip + None, Zip, Unzip -clean Clean game names according to WoD standards -dd, --dedup Enable deduping in the created DAT -gn=, --game-name= Filter by game name @@ -200,7 +205,16 @@ do partial matches using asterisks as follows (case insensitive): *00 means ends with '00' 00* means starts with '00' *00* means contains '00' - 00 means exactly equals '00'"); + 00 means exactly equals '00' + +Offline merge mode notes: + This program will output the following DATs: + (a) Net New - (NewComplete)-(Complete) + (b) Unneeded - (Complete)-(NewComplete) + (c) New Missing - (Net New)+(Missing-(Unneeded)) + (d) Have - (NewComplete)-(New Missing) + OR (Complete or NewComplete)-(Missing) if one is missing +"); break; case "Headerer": Console.WriteLine(@"Headerer - Remove and restore rom headers @@ -211,27 +225,6 @@ Options: -e Detect and remove mode -r Restore header to file based on SHA-1"); break; - case "OfflineMerge": - Console.WriteLine(@"OfflineMerge - Update DATS for offline arrays ------------------------------------------ -Usage: OfflineMerge [options] [inputs] - -Options: - -h, -?, --help Show this help dialog - -f, --fake Replace all hashes and sizes by the default - -Inputs: - -com= Complete current DAT - -fix= Complete current Missing - -new= New Complete DAT - -This program will output the following DATs: - (a) Net New - (NewComplete)-(Complete) - (b) Unneeded - (Complete)-(NewComplete) - (c) New Missing - (Net New)+(Missing-(Unneeded)) - (d) Have - (NewComplete)-(New Missing) - OR (Complete or NewComplete)-(Missing) if one is missing"); - break; default: Console.Write("This is the default help output"); break; diff --git a/SabreTools.Helper/SabreTools.Helper.csproj b/SabreTools.Helper/SabreTools.Helper.csproj index 76d6dca8..f0c4d962 100644 --- a/SabreTools.Helper/SabreTools.Helper.csproj +++ b/SabreTools.Helper/SabreTools.Helper.csproj @@ -8,7 +8,7 @@ Library Properties SabreTools.Helper - SabreTools + SabreTools.Helper v4.5.2 512 diff --git a/SabreTools.sln b/SabreTools.sln index 2338f7b7..6dad2856 100644 --- a/SabreTools.sln +++ b/SabreTools.sln @@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreToolsUI", "SabreToolsU EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Helper", "SabreTools.Helper\SabreTools.Helper.csproj", "{225A1AFD-0890-44E8-B779-7502665C23A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfflineMerge", "OfflineMerge\OfflineMerge.csproj", "{88310DB9-3B64-4268-AD48-2E0358D4CA5F}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,14 +48,6 @@ Global {225A1AFD-0890-44E8-B779-7502665C23A5}.Release|Any CPU.Build.0 = Release|Any CPU {225A1AFD-0890-44E8-B779-7502665C23A5}.Release|x64.ActiveCfg = Release|x64 {225A1AFD-0890-44E8-B779-7502665C23A5}.Release|x64.Build.0 = Release|x64 - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Debug|x64.ActiveCfg = Debug|x64 - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Debug|x64.Build.0 = Debug|x64 - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Release|Any CPU.Build.0 = Release|Any CPU - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Release|x64.ActiveCfg = Release|x64 - {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OfflineMerge/OfflineMerge.cs b/SabreTools/OfflineMerge.cs similarity index 85% rename from OfflineMerge/OfflineMerge.cs rename to SabreTools/OfflineMerge.cs index a9605487..4c287e77 100644 --- a/OfflineMerge/OfflineMerge.cs +++ b/SabreTools/OfflineMerge.cs @@ -33,113 +33,6 @@ namespace SabreTools _logger = logger; } - public static void Main(string[] args) - { - // Perform initial setup and verification - Logger logger = new Logger(true, "offlinemerge.log"); - logger.Start(); - - // If output is being redirected, don't allow clear screens - if (!Console.IsOutputRedirected) - { - Console.Clear(); - } - - // Credits take precidence over all - if ((new List(args)).Contains("--credits")) - { - Build.Credits(); - logger.Close(); - return; - } - - // If there's no arguments, show the help - if (args.Length == 0) - { - Build.Help(); - logger.Close(); - return; - } - - // Set all default values - bool help = false, fake = false, offlineMerge = true; - string currentAllMerged = "", currentMissingMerged = "", currentNewMerged = ""; - - // Determine which switches are enabled (with values if necessary) - foreach (string arg in args) - { - switch (arg) - { - case "-?": - case "-h": - case "--help": - help = true; - break; - case "-f": - case "--fake": - fake = true; - break; - default: - string temparg = arg.Replace("\"", ""); - if (temparg.StartsWith("-com=")) - { - currentAllMerged = temparg.Split('=')[1]; - } - else if (temparg.StartsWith("-fix=")) - { - currentMissingMerged = temparg.Split('=')[1]; - } - else if (temparg.StartsWith("-new=")) - { - currentNewMerged = temparg.Split('=')[1]; - } - else - { - logger.Warning("Invalid input detected: " + arg); - Console.WriteLine(); - Build.Help(); - logger.Close(); - return; - } - break; - } - } - - // If help is set, show help - if (help) - { - Build.Help(); - logger.Close(); - return; - } - - // Otherwise, run the program - if (offlineMerge) - { - if (!(currentAllMerged == "" && currentMissingMerged == "" && currentNewMerged == "")) - { - InitOfflineMerge(currentAllMerged, currentMissingMerged, currentNewMerged, fake, logger); - } - else - { - logger.User("All inputs were empty! At least one input is required..."); - Build.Help(); - logger.Close(); - return; - } - } - } - - private static void InitOfflineMerge(string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake, Logger logger) - { - OfflineMerge om = new OfflineMerge(currentAllMerged, currentMissingMerged, currentNewMerged, fake, logger); - bool success = om.Process(); - if (!success) - { - logger.Warning("At least one complete DAT and the fixdat is needed to run!"); - } - } - /// /// Process the supplied inputs and create the four outputs /// diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 7d64495d..c1349a99 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -503,6 +503,29 @@ namespace SabreTools hs.Process(); } + /// + /// Wrap creating an Offline merged DAT set + /// + /// Old-current DAT with merged and deduped values + /// Old-current missing DAT with merged and deduped values + /// New-current DAT with merged and deduped values + /// True if all values should be replaced with default 0-byte values, false otherwise + /// + private static void InitOfflineMerge(string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake) + { + // Sanitize the inputs + currentAllMerged = currentAllMerged.Replace("\"", ""); + currentMissingMerged = currentMissingMerged.Replace("\"", ""); + currentNewMerged = currentNewMerged.Replace("\"", ""); + + OfflineMerge om = new OfflineMerge(currentAllMerged, currentMissingMerged, currentNewMerged, fake, _logger); + bool success = om.Process(); + if (!success) + { + _logger.Warning("At least one complete DAT and the fixdat is needed to run!"); + } + } + /// /// Wrap getting statistics on a DAT or folder of DATs /// diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index a687f857..e91f5152 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -91,6 +91,7 @@ namespace SabreTools disableForce = false, enableGzip = false, extsplit = false, + fake = false, forceunpack = false, generate = false, genall = false, @@ -104,6 +105,7 @@ namespace SabreTools noMD5 = false, norename = false, noSHA1 = false, + offlineMerge = false, old = false, outputCMP = false, outputMiss = false, @@ -130,6 +132,9 @@ namespace SabreTools category = "", comment = "", crc = "", + currentAllMerged = "", + currentMissingMerged = "", + currentNewMerged = "", date = "", description = "", email = "", @@ -230,6 +235,10 @@ namespace SabreTools case "--files": archivesAsFiles = true; break; + case "-fk": + case "--fake": + fake = true; + break; case "-g": case "--generate": generate = true; @@ -302,6 +311,10 @@ namespace SabreTools case "--output-cmp": outputCMP = true; break; + case "-ol": + case "--offmerge": + offlineMerge = true; + break; case "-om": case "--output-miss": outputMiss = true; @@ -382,6 +395,10 @@ namespace SabreTools { comment = arg.Split('=')[1]; } + else if (arg.StartsWith("-com=") || arg.StartsWith("--com=")) + { + currentAllMerged = arg.Split('=')[1]; + } else if (arg.StartsWith("-crc=") || arg.StartsWith("--crc=")) { crc = arg.Split('=')[1]; @@ -410,6 +427,10 @@ namespace SabreTools { filename = arg.Split('=')[1]; } + else if (arg.StartsWith("-fix=") || arg.StartsWith("--fix=")) + { + currentMissingMerged = arg.Split('=')[1]; + } else if (arg.StartsWith("-fm=") || arg.StartsWith("--forcemerge=")) { forcemerge = arg.Split('=')[1]; @@ -450,6 +471,10 @@ namespace SabreTools { name = arg.Split('=')[1]; } + else if (arg.StartsWith("-new=") || arg.StartsWith("--new=")) + { + currentNewMerged = arg.Split('=')[1]; + } else if (arg.StartsWith("-out=") && outdir == "") { outdir = arg.Split('=')[1]; @@ -558,8 +583,9 @@ namespace SabreTools } // If more than one switch is enabled, show the help screen - if (!(add ^ datfromdir ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ (merge || diff) ^ - (update || outputCMP || outputRC || outputSD || outputXML || outputMiss || romba) ^ rem ^ stats ^ trim)) + if (!(add ^ datfromdir ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ + (merge || diff) ^ (update || outputCMP || outputRC || outputSD || outputXML || outputMiss || romba) ^ + offlineMerge ^ rem ^ stats ^ trim)) { _logger.Error("Only one feature switch is allowed at a time"); Build.Help(); @@ -696,6 +722,22 @@ namespace SabreTools InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, old, romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir); } + // If we want to run Offline merging mode + else if (offlineMerge) + { + if (!(currentAllMerged == "" && currentMissingMerged == "" && currentNewMerged == "")) + { + InitOfflineMerge(currentAllMerged, currentMissingMerged, currentNewMerged, fake); + } + else + { + _logger.User("All inputs were empty! At least one input is required..."); + Build.Help(); + _logger.Close(); + return; + } + } + // If nothing is set, show the help else { diff --git a/SabreTools/SabreTools.csproj b/SabreTools/SabreTools.csproj index 0fcf24af..79c342a4 100644 --- a/SabreTools/SabreTools.csproj +++ b/SabreTools/SabreTools.csproj @@ -109,6 +109,7 @@ +