[DATFromDir] Integrate DATFromDir into DATabase

This commit is contained in:
Matt Nadareski
2016-06-11 15:42:49 -07:00
parent 9571a1ad39
commit b058c8ed24
12 changed files with 117 additions and 168 deletions

3
.gitignore vendored
View File

@@ -2,9 +2,6 @@
/DATabase/obj /DATabase/obj
/DATabase/obj/Debug /DATabase/obj/Debug
/DATabase/obj/Release /DATabase/obj/Release
/DATFromDir/obj
/DATFromDir/obj/Debug
/DATFromDir/obj/Release
/Deheader/obj /Deheader/obj
/Deheader/obj/Debug /Deheader/obj/Debug
/Deheader/obj/Release /Deheader/obj/Release

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@@ -1,94 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{382B75D3-079E-49D5-A830-54DD6EB5A02D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DATFromDir</RootNamespace>
<AssemblyName>DATFromDir</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\Debug-x64\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\..\Release-x64\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="SharpCompress, Version=0.11.6.0, Culture=neutral, PublicKeyToken=beaf6f427e128133, processorArchitecture=MSIL">
<HintPath>..\packages\sharpcompress.0.11.6\lib\net40\SharpCompress.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DATFromDir.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreHelper\SabreHelper.csproj">
<Project>{225a1afd-0890-44e8-b779-7502665c23a5}</Project>
<Name>SabreHelper</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -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")]

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="sharpcompress" version="0.11.6" targetFramework="net452" />
</packages>

View File

@@ -109,7 +109,7 @@ namespace SabreTools
case "--gz-files": case "--gz-files":
enableGzip = true; enableGzip = true;
break; break;
case "-m": case "-nm":
case "--noMD5": case "--noMD5":
noMD5 = true; noMD5 = true;
break; break;

View File

@@ -80,15 +80,17 @@ namespace SabreTools
// Set all default values // Set all default values
bool help = false, bool help = false,
add = false, add = false,
archivesAsFiles = false,
bare = false, bare = false,
cascade = false, cascade = false,
clean = false, clean = false,
datfromdir = false,
datprefix = false, datprefix = false,
dedup = false, dedup = false,
diff = false, diff = false,
disableForce = false, disableForce = false,
enableGzip = false,
extsplit = false, extsplit = false,
filter = false,
forceunpack = false, forceunpack = false,
generate = false, generate = false,
genall = false, genall = false,
@@ -99,7 +101,9 @@ namespace SabreTools
listsrc = false, listsrc = false,
listsys = false, listsys = false,
merge = false, merge = false,
noMD5 = false,
norename = false, norename = false,
noSHA1 = false,
old = false, old = false,
outputCMP = false, outputCMP = false,
outputMiss = false, outputMiss = false,
@@ -151,6 +155,7 @@ namespace SabreTools
sources = "", sources = "",
systems = "", systems = "",
root = "", root = "",
tempdir = "",
url = "", url = "",
version = ""; version = "";
List<string> inputs = new List<string>(); List<string> inputs = new List<string>();
@@ -201,6 +206,10 @@ namespace SabreTools
case "--clean": case "--clean":
clean = true; clean = true;
break; break;
case "-d":
case "--dfd":
datfromdir = true;
break;
case "-dd": case "-dd":
case "--dedup": case "--dedup":
dedup = true; dedup = true;
@@ -218,8 +227,8 @@ namespace SabreTools
extsplit = true; extsplit = true;
break; break;
case "-f": case "-f":
case "--filter": case "--files":
filter = true; archivesAsFiles = true;
break; break;
case "-g": case "-g":
case "--generate": case "--generate":
@@ -233,6 +242,10 @@ namespace SabreTools
case "--game-prefix": case "--game-prefix":
datprefix = true; datprefix = true;
break; break;
case "-gz":
case "--gz-files":
enableGzip = true;
break;
case "-hs": case "-hs":
case "--hash-split": case "--hash-split":
hashsplit = true; hashsplit = true;
@@ -265,6 +278,10 @@ namespace SabreTools
case "--nodump": case "--nodump":
nodump = true; nodump = true;
break; break;
case "-nm":
case "--noMD5":
noMD5 = true;
break;
case "-nnd": case "-nnd":
case "--not-nodump": case "--not-nodump":
nodump = false; nodump = false;
@@ -273,6 +290,10 @@ namespace SabreTools
case "--no-rename": case "--no-rename":
norename = true; norename = true;
break; break;
case "-ns":
case "--noSHA1":
noSHA1 = true;
break;
case "-o": case "-o":
case "--old": case "--old":
old = true; old = true;
@@ -441,6 +462,14 @@ namespace SabreTools
{ {
prefix = arg.Split('=')[1]; 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=")) else if (arg.StartsWith("-rn=") || arg.StartsWith("--rom-name="))
{ {
romname = arg.Split('=')[1]; romname = arg.Split('=')[1];
@@ -482,13 +511,9 @@ namespace SabreTools
{ {
systems = arg.Split('=')[1]; 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]; tempdir = arg.Split('=')[1];
}
else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext="))
{
repext = arg.Split('=')[1];
} }
else if (arg.StartsWith("-u=") || arg.StartsWith("--url=")) 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 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)) (update || outputCMP || outputRC || outputSD || outputXML || outputMiss || romba) ^ rem ^ stats ^ trim))
{ {
_logger.Error("Only one feature switch is allowed at a time"); _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 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 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"); _logger.Error("This feature requires at least one input");
Build.Help(); Build.Help();
@@ -587,7 +612,7 @@ namespace SabreTools
} }
// Convert, update, and filter a DAT or folder of DATs // 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) foreach (string input in inputs)
{ {
@@ -665,6 +690,12 @@ namespace SabreTools
InitStats(inputs, single); 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 // If nothing is set, show the help
else else
{ {

View File

@@ -82,6 +82,10 @@
<HintPath>..\packages\Mono.Data.Sqlite.Portable.1.0.3.5\lib\net4\Mono.Data.Sqlite.dll</HintPath> <HintPath>..\packages\Mono.Data.Sqlite.Portable.1.0.3.5\lib\net4\Mono.Data.Sqlite.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="SharpCompress, Version=0.11.6.0, Culture=neutral, PublicKeyToken=beaf6f427e128133, processorArchitecture=MSIL">
<HintPath>..\packages\sharpcompress.0.11.6\lib\net40\SharpCompress.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -104,6 +108,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DATFromDir.cs" />
<Compile Include="Split.cs" /> <Compile Include="Split.cs" />
<Compile Include="ImportExport\Generate.cs" /> <Compile Include="ImportExport\Generate.cs" />
<Compile Include="ImportExport\GenerateTwo.cs" /> <Compile Include="ImportExport\GenerateTwo.cs" />

View File

@@ -291,6 +291,71 @@ namespace SabreTools
} }
} }
/// <summary>
/// Wrap creating a DAT file from files or a directory
/// </summary>
/// <param name="input">List of innput filenames</param>
/// <param name="filename">New filename</param>
/// <param name="name">New name</param>
/// <param name="description">New description</param>
/// <param name="category">New category</param>
/// <param name="version">New version</param>
/// <param name="author">New author</param>
/// <param name="forceunpack">True to set forcepacking="unzip" on the created file, false otherwise</param>
/// <param name="old">True to output in CMP format, false to output in Logiqx XML</param>
/// <param name="romba">True to enable reading a directory like a Romba depot, false otherwise</param>
/// <param name="superdat">True to enable SuperDAT-style reading, false otherwise</param>
/// <param name="noMD5">True to disable getting MD5 hash, false otherwise</param>
/// <param name="noSHA1">True to disable getting SHA-1 hash, false otherwise</param>
/// <param name="bare">True if the date should be omitted from the DAT, false otherwise</param>
/// <param name="archivesAsFiles">True if archives should be treated as files, false otherwise</param>
/// <param name="enableGzip">True if GZIP archives should be treated as files, false otherwise</param>
/// <param name="tempDir">Name of the directory to create a temp folder in (blank is current directory</param>
private static void InitDatFromDir(List<string> 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<string, List<RomData>>(),
};
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();
}
}
/// <summary> /// <summary>
/// Wrap trimming and merging a single DAT /// Wrap trimming and merging a single DAT
/// </summary> /// </summary>

View File

@@ -2,4 +2,5 @@
<packages> <packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net452" /> <package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="Mono.Data.Sqlite.Portable" version="1.0.3.5" targetFramework="net452" /> <package id="Mono.Data.Sqlite.Portable" version="1.0.3.5" targetFramework="net452" />
<package id="sharpcompress" version="0.11.6" targetFramework="net452" />
</packages> </packages>

View File

@@ -201,8 +201,8 @@ Usage: DATFromDir [options] [filename|dirname] <filename|dirname> ...
Options: Options:
-h, -?, --help Show this help dialog -h, -?, --help Show this help dialog
-m, --noMD5 Don't include MD5 in output -nm, --noMD5 Don't include MD5 in output
-s, --noSHA1 Don't include SHA1 in output -ns, --noSHA1 Don't include SHA1 in output
-b, --bare Don't include date in file name -b, --bare Don't include date in file name
-u, --unzip Force unzipping in created DAT -u, --unzip Force unzipping in created DAT
-f, --files Treat archives as files -f, --files Treat archives as files

View File

@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreToolsUI", "SabreToolsU
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreHelper", "SabreHelper\SabreHelper.csproj", "{225A1AFD-0890-44E8-B779-7502665C23A5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreHelper", "SabreHelper\SabreHelper.csproj", "{225A1AFD-0890-44E8-B779-7502665C23A5}"
EndProject 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfflineMerge", "OfflineMerge\OfflineMerge.csproj", "{88310DB9-3B64-4268-AD48-2E0358D4CA5F}"
EndProject EndProject
Global 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|Any CPU.Build.0 = Release|Any CPU
{225A1AFD-0890-44E8-B779-7502665C23A5}.Release|x64.ActiveCfg = Release|x64 {225A1AFD-0890-44E8-B779-7502665C23A5}.Release|x64.ActiveCfg = Release|x64
{225A1AFD-0890-44E8-B779-7502665C23A5}.Release|x64.Build.0 = 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.ActiveCfg = Debug|Any CPU
{88310DB9-3B64-4268-AD48-2E0358D4CA5F}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Debug|x64