diff --git a/.gitignore b/.gitignore index 2be996f7..59a33272 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,6 @@ /DATabase/obj /DATabase/obj/Debug /DATabase/obj/Release -/DATFromDir/obj -/DATFromDir/obj/Debug -/DATFromDir/obj/Release /Deheader/obj /Deheader/obj/Debug /Deheader/obj/Release diff --git a/DATFromDir/App.config b/DATFromDir/App.config deleted file mode 100644 index 88fa4027..00000000 --- a/DATFromDir/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DATFromDir/DATFromDir.csproj b/DATFromDir/DATFromDir.csproj deleted file mode 100644 index 661116c6..00000000 --- a/DATFromDir/DATFromDir.csproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - - Debug - AnyCPU - {382B75D3-079E-49D5-A830-54DD6EB5A02D} - Exe - Properties - DATFromDir - DATFromDir - 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 - - - - ..\packages\sharpcompress.0.11.6\lib\net40\SharpCompress.dll - True - - - - - - - - - - - - - - - - - - - - - - - - {225a1afd-0890-44e8-b779-7502665c23a5} - SabreHelper - - - - - \ No newline at end of file diff --git a/DATFromDir/Properties/AssemblyInfo.cs b/DATFromDir/Properties/AssemblyInfo.cs deleted file mode 100644 index 0d9500f6..00000000 --- a/DATFromDir/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("DATFromDir")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DATFromDir")] -[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("382b75d3-079e-49d5-a830-54dd6eb5a02d")] - -// 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/DATFromDir/packages.config b/DATFromDir/packages.config deleted file mode 100644 index b19639c6..00000000 --- a/DATFromDir/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/DATFromDir/DATFromDir.cs b/DATabase/DATFromDir.cs similarity index 99% rename from DATFromDir/DATFromDir.cs rename to DATabase/DATFromDir.cs index dadb3c08..f0d58596 100644 --- a/DATFromDir/DATFromDir.cs +++ b/DATabase/DATFromDir.cs @@ -109,7 +109,7 @@ namespace SabreTools case "--gz-files": enableGzip = true; break; - case "-m": + case "-nm": case "--noMD5": noMD5 = true; break; diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index a309d31b..5efaea95 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -80,15 +80,17 @@ namespace SabreTools // Set all default values bool help = false, add = false, + archivesAsFiles = false, bare = false, cascade = false, clean = false, + datfromdir = false, datprefix = false, dedup = false, diff = false, disableForce = false, + enableGzip = false, extsplit = false, - filter = false, forceunpack = false, generate = false, genall = false, @@ -99,7 +101,9 @@ namespace SabreTools listsrc = false, listsys = false, merge = false, + noMD5 = false, norename = false, + noSHA1 = false, old = false, outputCMP = false, outputMiss = false, @@ -151,6 +155,7 @@ namespace SabreTools sources = "", systems = "", root = "", + tempdir = "", url = "", version = ""; List inputs = new List(); @@ -201,6 +206,10 @@ namespace SabreTools case "--clean": clean = true; break; + case "-d": + case "--dfd": + datfromdir = true; + break; case "-dd": case "--dedup": dedup = true; @@ -218,8 +227,8 @@ namespace SabreTools extsplit = true; break; case "-f": - case "--filter": - filter = true; + case "--files": + archivesAsFiles = true; break; case "-g": case "--generate": @@ -233,6 +242,10 @@ namespace SabreTools case "--game-prefix": datprefix = true; break; + case "-gz": + case "--gz-files": + enableGzip = true; + break; case "-hs": case "--hash-split": hashsplit = true; @@ -265,6 +278,10 @@ namespace SabreTools case "--nodump": nodump = true; break; + case "-nm": + case "--noMD5": + noMD5 = true; + break; case "-nnd": case "--not-nodump": nodump = false; @@ -273,6 +290,10 @@ namespace SabreTools case "--no-rename": norename = true; break; + case "-ns": + case "--noSHA1": + noSHA1 = true; + break; case "-o": case "--old": old = true; @@ -441,6 +462,14 @@ namespace SabreTools { prefix = arg.Split('=')[1]; } + else if (arg.StartsWith("-rd=") || arg.StartsWith("--root-dir=")) + { + root = arg.Split('=')[1]; + } + else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext=")) + { + repext = arg.Split('=')[1]; + } else if (arg.StartsWith("-rn=") || arg.StartsWith("--rom-name=")) { romname = arg.Split('=')[1]; @@ -482,13 +511,9 @@ namespace SabreTools { systems = arg.Split('=')[1]; } - else if (arg.StartsWith("-rd=") || arg.StartsWith("--root-dir=")) + else if (arg.StartsWith("-t=") || arg.StartsWith("--temp=")) { - root = arg.Split('=')[1]; - } - else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext=")) - { - repext = arg.Split('=')[1]; + tempdir = arg.Split('=')[1]; } else if (arg.StartsWith("-u=") || arg.StartsWith("--url=")) { @@ -533,7 +558,7 @@ namespace SabreTools } // If more than one switch is enabled, show the help screen - if (!(add ^ extsplit ^ filter ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ (merge || diff) ^ + if (!(add ^ datfromdir ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ (merge || diff) ^ (update || outputCMP || outputRC || outputSD || outputXML || outputMiss || romba) ^ rem ^ stats ^ trim)) { _logger.Error("Only one feature switch is allowed at a time"); @@ -544,7 +569,7 @@ namespace SabreTools // If a switch that requires a filename is set and no file is, show the help screen if (inputs.Count == 0 && (update || (outputMiss || romba) || outputCMP || outputRC || outputSD - || outputXML || filter || extsplit || hashsplit || (merge || diff) || stats || trim)) + || outputXML || extsplit || hashsplit || datfromdir || (merge || diff) || stats || trim)) { _logger.Error("This feature requires at least one input"); Build.Help(); @@ -587,7 +612,7 @@ namespace SabreTools } // Convert, update, and filter a DAT or folder of DATs - else if (update || outputCMP || outputMiss || outputRC || outputSD || outputXML || romba || filter) + else if (update || outputCMP || outputMiss || outputRC || outputSD || outputXML || romba) { foreach (string input in inputs) { @@ -665,6 +690,12 @@ namespace SabreTools InitStats(inputs, single); } + // Create a DAT from a directory or set of directories + else if (datfromdir) + { + InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, old, romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir); + } + // If nothing is set, show the help else { diff --git a/DATabase/DATabase.csproj b/DATabase/DATabase.csproj index 359275e6..7683a74d 100644 --- a/DATabase/DATabase.csproj +++ b/DATabase/DATabase.csproj @@ -82,6 +82,10 @@ ..\packages\Mono.Data.Sqlite.Portable.1.0.3.5\lib\net4\Mono.Data.Sqlite.dll True + + ..\packages\sharpcompress.0.11.6\lib\net40\SharpCompress.dll + True + @@ -104,6 +108,7 @@ + diff --git a/DATabase/Partials/DATabase_Inits.cs b/DATabase/Partials/DATabase_Inits.cs index 0cc739cc..f2bfd71a 100644 --- a/DATabase/Partials/DATabase_Inits.cs +++ b/DATabase/Partials/DATabase_Inits.cs @@ -291,6 +291,71 @@ namespace SabreTools } } + /// + /// Wrap creating a DAT file from files or a directory + /// + /// List of innput filenames + /// New filename + /// New name + /// New description + /// New category + /// New version + /// New author + /// True to set forcepacking="unzip" on the created file, false otherwise + /// True to output in CMP format, false to output in Logiqx XML + /// True to enable reading a directory like a Romba depot, false otherwise + /// True to enable SuperDAT-style reading, false otherwise + /// True to disable getting MD5 hash, false otherwise + /// True to disable getting SHA-1 hash, false otherwise + /// True if the date should be omitted from the DAT, false otherwise + /// True if archives should be treated as files, false otherwise + /// True if GZIP archives should be treated as files, false otherwise + /// Name of the directory to create a temp folder in (blank is current directory + private static void InitDatFromDir(List inputs, + string filename, + string name, + string description, + string category, + string version, + string author, + bool forceunpack, + bool old, + bool romba, + bool superdat, + bool noMD5, + bool noSHA1, + bool bare, + bool archivesAsFiles, + bool enableGzip, + string tempDir) + { + // Create a new DATFromDir object and process the inputs + DatData datdata = new DatData + { + FileName = description, + Name = name, + Description = description, + Category = category, + Version = version, + Date = DateTime.Now.ToString("yyyy-MM-dd"), + Author = author, + ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None), + OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml), + Romba = romba, + Type = (superdat ? "SuperDAT" : ""), + Roms = new Dictionary>(), + }; + DATFromDir dfd = new DATFromDir(inputs, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, _logger); + bool success = dfd.Start(); + + // If we failed, show the help + if (!success) + { + Console.WriteLine(); + Build.Help(); + } + } + /// /// Wrap trimming and merging a single DAT /// diff --git a/DATabase/packages.config b/DATabase/packages.config index ce34d545..6e11d9ba 100644 --- a/DATabase/packages.config +++ b/DATabase/packages.config @@ -2,4 +2,5 @@ + \ No newline at end of file diff --git a/SabreHelper/Data/Build.cs b/SabreHelper/Data/Build.cs index 11ff4c2f..c1dd72a3 100644 --- a/SabreHelper/Data/Build.cs +++ b/SabreHelper/Data/Build.cs @@ -201,8 +201,8 @@ Usage: DATFromDir [options] [filename|dirname] ... Options: -h, -?, --help Show this help dialog - -m, --noMD5 Don't include MD5 in output - -s, --noSHA1 Don't include SHA1 in output + -nm, --noMD5 Don't include MD5 in output + -ns, --noSHA1 Don't include SHA1 in output -b, --bare Don't include date in file name -u, --unzip Force unzipping in created DAT -f, --files Treat archives as files diff --git a/SabreTools.sln b/SabreTools.sln index 46bc1c2a..e816810e 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}") = "SabreHelper", "SabreHelper\SabreHelper.csproj", "{225A1AFD-0890-44E8-B779-7502665C23A5}" 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 @@ -52,14 +50,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 - {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Debug|x64.ActiveCfg = Debug|x64 - {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Debug|x64.Build.0 = Debug|x64 - {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 - {382B75D3-079E-49D5-A830-54DD6EB5A02D}.Release|x64.ActiveCfg = Release|x64 - {382B75D3-079E-49D5-A830-54DD6EB5A02D}.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