From 27aea4a443abbb52f46c0470a049031cf4b802da Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 28 Apr 2016 14:08:06 -0700 Subject: [PATCH] Add new project for Offline Merging The outputs from this program help with organizing roms that are in hard drives that are disconnected from the computer. This is mainly for people with disconnected arrays, but can be used to maintain a "best missing" list at all times as well. --- .gitignore | 3 + OfflineMerge/App.config | 6 ++ OfflineMerge/OfflineMerge.cs | 84 +++++++++++++++++++++++++ OfflineMerge/OfflineMerge.csproj | 66 +++++++++++++++++++ OfflineMerge/Properties/AssemblyInfo.cs | 36 +++++++++++ SabreTools.sln | 6 ++ 6 files changed, 201 insertions(+) create mode 100644 OfflineMerge/App.config create mode 100644 OfflineMerge/OfflineMerge.cs create mode 100644 OfflineMerge/OfflineMerge.csproj create mode 100644 OfflineMerge/Properties/AssemblyInfo.cs diff --git a/.gitignore b/.gitignore index 311dad85..2be996f7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ /Deheader/obj /Deheader/obj/Debug /Deheader/obj/Release +/OfflineMerge/obj +/OfflineMerge/obj/Debug +/OfflineMerge/obj/Release /SabreHelper/obj /SabreHelper/obj/Debug /SabreHelper/obj/Release diff --git a/OfflineMerge/App.config b/OfflineMerge/App.config new file mode 100644 index 00000000..88fa4027 --- /dev/null +++ b/OfflineMerge/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OfflineMerge/OfflineMerge.cs b/OfflineMerge/OfflineMerge.cs new file mode 100644 index 00000000..f52505e0 --- /dev/null +++ b/OfflineMerge/OfflineMerge.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SabreTools.Helper; + +namespace SabreTools +{ + /* + "Special Merge" by Obiwantje + ------------------------ + Inputs: + (1) All - Current all merged + (2) Missing - Current all missing + (3) Add - Current to add + (4) All-New - Current with replaced DATs (some add/remove) + (5) [Flag] Set all roms to have 0-byte values; if set, prepend "Offline" to DAT name/desc + + 0-byte Values: + CRC - 00000000 + MD5 - d41d8cd98f00b204e9800998ecf8427e + SHA-1 - da39a3ee5e6b4b0d3255bfef95601890afd80709 + */ + public class OfflineMerge + { + // Instance variables + private string _currentAllMerged; + private string _currentAllMissing; + private List _toAdd; + private string _currentWithReplaced; + private bool _fake; + private Logger _logger; + + /// + /// Instantiate an OfflineMerge object + /// + /// Old-current DAT with merged values + /// Old-current missing DAT with merged values + /// List of new files to merge in + /// New-current DAT with merged values + /// True if all values should be replaced with default 0-byte values, false otherwise + /// Logger object for console and file output + public OfflineMerge (string currentAllMerged, string currentAllMissing, string toAdd, string currentWithReplaced, bool fake, Logger logger) + { + _currentAllMerged = currentAllMerged.Replace("\"", ""); + _currentAllMissing = currentAllMissing.Replace("\"", ""); + _toAdd = new List(); + if (File.Exists(toAdd.Replace("\"", ""))) + { + _toAdd.Add(toAdd.Replace("\"", "")); + } + else if (Directory.Exists(toAdd.Replace("\"", ""))) + { + foreach (string file in Directory.EnumerateFiles(toAdd, "*", SearchOption.AllDirectories)) + { + _toAdd.Add(file); + } + } + _currentWithReplaced = currentWithReplaced; + _fake = fake; + _logger = logger; + } + + public static void Main(string[] args) + { + // Read in inputs and start the processing + } + + /// + /// Process the supplied inputs and create the three required outputs: + /// (a) Net-New - (currentWithReplaced)-(currentAllMerged) + /// (b) New Missing - (a)+(currentAllMissing) + /// (c) Unneeded - (currentAllMerged)-(currentWithReplaced) + /// + /// True if the files were created properly, false otherwise + public bool Process() + { + return true; + } + } +} diff --git a/OfflineMerge/OfflineMerge.csproj b/OfflineMerge/OfflineMerge.csproj new file mode 100644 index 00000000..0f076857 --- /dev/null +++ b/OfflineMerge/OfflineMerge.csproj @@ -0,0 +1,66 @@ + + + + + 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 + + + + + + + + + + + + + + + + + + + + + {225a1afd-0890-44e8-b779-7502665c23a5} + SabreHelper + + + + + \ No newline at end of file diff --git a/OfflineMerge/Properties/AssemblyInfo.cs b/OfflineMerge/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7a77ff03 --- /dev/null +++ b/OfflineMerge/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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.sln b/SabreTools.sln index b16ceebc..82b4a281 100644 --- a/SabreTools.sln +++ b/SabreTools.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreHelper", "SabreHelper\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DATFromDir", "DATFromDir\DATFromDir.csproj", "{382B75D3-079E-49D5-A830-54DD6EB5A02D}" 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 @@ -40,6 +42,10 @@ Global {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Debug|Any CPU.Build.0 = Debug|Any CPU {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Release|Any CPU.ActiveCfg = Release|Any CPU {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Release|Any CPU.Build.0 = Release|Any CPU + {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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE