Create simple Dir2DAT program for internal use

This commit is contained in:
Matt Nadareski
2016-04-11 15:09:50 -07:00
parent 72c4a95ae3
commit eb02006c97
14 changed files with 547 additions and 0 deletions

BIN
DATFromDir/7z/7za.dll Normal file

Binary file not shown.

BIN
DATFromDir/7z/7za.exe Normal file

Binary file not shown.

BIN
DATFromDir/7z/7zxa.dll Normal file

Binary file not shown.

31
DATFromDir/7z/License.txt Normal file
View File

@@ -0,0 +1,31 @@
7-Zip Extra
~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright (C) 1999-2015 Igor Pavlov.
7-Zip Extra files are under the GNU LGPL license.
Notes:
You can use 7-Zip Extra on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/

77
DATFromDir/7z/history.txt Normal file
View File

@@ -0,0 +1,77 @@
7-Zip Extra history
-------------------
9.35 beta 2014-12-07
------------------------------
- SFX modules were moved to LZMA SDK package.
9.34 alpha 2014-06-22
------------------------------
- Minimum supported system now is Windows 2000 for EXE and DLL files.
- all EXE and DLL files use msvcrt.dll.
- 7zr.exe now support AES encryption.
9.18 2010-11-02
------------------------------
- New small SFX module for installers.
9.17 2010-10-04
------------------------------
- New 7-Zip plugin for FAR Manager x64.
9.10 2009-12-30
------------------------------
- 7-Zip for installers now supports LZMA2.
9.09 2009-12-12
------------------------------
- LZMA2 compression method support.
- Some bugs were fixed.
4.65 2009-02-03
------------------------------
- Some bugs were fixed.
4.38 beta 2006-04-13
------------------------------
- SFX for installers now supports new properties in config file:
Progress, Directory, ExecuteFile, ExecuteParameters.
4.34 beta 2006-02-27
------------------------------
- ISetProperties::SetProperties:
it's possible to specify desirable number of CPU threads:
PROPVARIANT: name=L"mt", vt = VT_UI4, ulVal = NumberOfThreads
If "mt" is not defined, 7za.dll will check number of processors in system to set
number of desirable threads.
Now 7za.dll can use:
2 threads for LZMA compressing
N threads for BZip2 compressing
4 threads for BZip2 decompressing
Other codecs use only one thread.
Note: 7za.dll can use additional "small" threads with low CPU load.
- It's possible to call ISetProperties::SetProperties to specify "mt" property for decoder.
4.33 beta 2006-02-05
------------------------------
- Compressing speed and Memory requirements were increased.
Default dictionary size was increased: Fastest: 64 KB, Fast: 1 MB,
Normal: 4 MB, Max: 16 MB, Ultra: 64 MB.
- 7z/LZMA now can use only these match finders: HC4, BT2, BT3, BT4
4.27 2005-09-21
------------------------------
- Some GUIDs/interfaces were changed.
IStream.h:
ISequentialInStream::Read now works as old ReadPart
ISequentialOutStream::Write now works as old WritePart

124
DATFromDir/7z/readme.txt Normal file
View File

@@ -0,0 +1,124 @@
7-Zip Extra 15.14
-----------------
7-Zip Extra is package of extra modules of 7-Zip.
7-Zip Copyright (C) 1999-2015 Igor Pavlov.
7-Zip is free software. Read License.txt for more information about license.
Source code of binaries can be found at:
http://www.7-zip.org/
This package contains the following files:
7za.exe - standalone console version of 7-Zip with reduced formats support.
7za.dll - library for working with 7z archives
7zxa.dll - library for extracting from 7z archives
License.txt - license information
readme.txt - this file
Far\ - plugin for Far Manager
x64\ - binaries for x64
All 32-bit binaries can work in:
Windows 2000 / 2003 / 2008 / XP / Vista / 7 / 8 / 10
and in any Windows x64 version with WoW64 support.
All x64 binaries can work in any Windows x64 version.
All binaries use msvcrt.dll.
7za.exe
-------
7za.exe - is a standalone console version of 7-Zip with reduced formats support.
Extra: 7za.exe : support for only some formats of 7-Zip.
7-Zip: 7z.exe with 7z.dll : support for all formats of 7-Zip.
7za.exe and 7z.exe from 7-Zip have same command line interface.
7za.exe doesn't use external DLL files.
You can read Help File (7-zip.chm) from 7-Zip package for description
of all commands and switches for 7za.exe and 7z.exe.
7za.exe features:
- High compression ratio in 7z format
- Supported formats:
- Packing / unpacking: 7z, xz, ZIP, GZIP, BZIP2 and TAR
- Unpacking only: Z, lzma, CAB.
- Highest compression ratio for ZIP and GZIP formats.
- Fast compression and decompression
- Strong AES-256 encryption in 7z and ZIP formats.
Note: LZMA SDK contains 7zr.exe - more reduced version of 7za.exe.
But you can use 7zr.exe as "public domain" code.
DLL files
---------
7za.dll and 7zxa.dll are reduced versions of 7z.dll from 7-Zip.
7za.dll and 7zxa.dll support only 7z format.
Note: 7z.dll is main DLL file that works with all archive types in 7-Zip.
7za.dll and 7zxa.dll support the following decoding methods:
- LZMA, LZMA2, PPMD, BCJ, BCJ2, COPY, 7zAES, BZip2, Deflate.
7za.dll also supports 7z encoding with the following encoding methods:
- LZMA, LZMA2, PPMD, BCJ, BCJ2, COPY, 7zAES.
7za.dll and 7zxa.dll work via COM interfaces.
But these DLLs don't use standard COM interfaces for objects creating.
Look also example code that calls DLL functions (in source code of 7-Zip):
7zip\UI\Client7z
Another example of binary that uses these interface is 7-Zip itself.
The following binaries from 7-Zip use 7z.dll:
- 7z.exe (console version)
- 7zG.exe (GUI version)
- 7zFM.exe (7-Zip File Manager)
Note: The source code of LZMA SDK also contains the code for similar DLLs
(DLLs without BZip2, Deflate support). And these files from LZMA SDK can be
used as "public domain" code. If you use LZMA SDK files, you don't need to
follow GNU LGPL rules, if you want to change the code.
License FAQ
-----------
Can I use the EXE or DLL files from 7-Zip in a commercial application?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yes, but you are required to specify in documentation for your application:
(1) that you used parts of the 7-Zip program,
(2) that 7-Zip is licensed under the GNU LGPL license and
(3) you must give a link to www.7-zip.org, where the source code can be found.
Can I use the source code of 7-Zip in a commercial application?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since 7-Zip is licensed under the GNU LGPL you must follow the rules of that license.
In brief, it means that any LGPL'ed code must remain licensed under the LGPL.
For instance, you can change the code from 7-Zip or write a wrapper for some
code from 7-Zip and compile it into a DLL; but, the source code of that DLL
(including your modifications / additions / wrapper) must be licensed under
the LGPL or GPL.
Any other code in your application can be licensed as you wish. This scheme allows
users and developers to change LGPL'ed code and recompile that DLL. That is the
idea of free software. Read more here: http://www.gnu.org/.
Note: You can look also LZMA SDK, which is available under a more liberal license.
---
End of document

BIN
DATFromDir/7z/x64/7za.dll Normal file

Binary file not shown.

BIN
DATFromDir/7z/x64/7za.exe Normal file

Binary file not shown.

BIN
DATFromDir/7z/x64/7zxa.dll Normal file

Binary file not shown.

6
DATFromDir/App.config Normal file
View File

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

177
DATFromDir/DATFromDir.cs Normal file
View File

@@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace SabreTools
{
class DATFromDir
{
private static string _7zPath;
private static string _basePath;
private static string _tempDir;
private static string _baseExtract;
static void Main(string[] args)
{
// Set local paths
_7zPath = Environment.CurrentDirectory.Replace('/', '\\') + "\\7z" + (Environment.Is64BitOperatingSystem ? "\\x64" : "") + "\\";
_tempDir = Environment.CurrentDirectory.Replace('/', '\\') + "\\temp" + DateTime.Now.ToString("yyyyMMddHHmmss") + "\\";
_basePath = (args.Length == 0 ? Environment.CurrentDirectory : args[0]).Replace('/', '\\') + "\\";
// Set base arguments to be used
_baseExtract = "x -o\"" + _tempDir + "\"";
// Set the basic Process information for 7za
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = _7zPath + "7za.exe",
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
};
// Get an output array going that has the right mappings (parent, name, size, hash)
List<Tuple<string, string, long, string>> roms = new List<Tuple<string, string, long, string>>();
// This is where the main loop would go
foreach (string item in Directory.EnumerateFileSystemEntries(_basePath))
{
// Create the temporary output directory
Directory.CreateDirectory(_tempDir);
psi.Arguments = _baseExtract + " " + item;
Process zip = Process.Start(psi);
zip.WaitForExit();
bool encounteredErrors = zip.StandardError.ReadToEnd().Contains("ERROR");
// Get a list of files including size and hash
SHA1 sha1 = SHA1.Create();
// If the file was an archive and was extracted successfully, check it
if (!encounteredErrors)
{
foreach (string entry in Directory.GetFiles(_tempDir, "*", SearchOption.AllDirectories))
{
FileStream fs = File.OpenRead(entry);
string tempHash = BitConverter.ToString(sha1.ComputeHash(fs)).Replace("-", "");
fs.Close();
roms.Add(new Tuple<string, string, long, string>(Path.GetFileNameWithoutExtension(item), entry.Remove(0, _tempDir.Length), (new FileInfo(entry)).Length, tempHash));
}
}
// Otherwise, just get the info on the file itself
else
{
FileStream fs = File.OpenRead(item);
string tempHash = BitConverter.ToString(sha1.ComputeHash(fs)).Replace("-", "");
fs.Close();
roms.Add(new Tuple<string, string, long, string>("Default", item.Remove(0, _basePath.Length), (new FileInfo(item)).Length, tempHash));
}
// Delete the temp directory
Directory.Delete(_tempDir, true);
}
// Order the roms by name of parent, then name of rom
roms.Sort(delegate (Tuple<string, string, long, string> A, Tuple<string, string, long, string> B)
{
if (A.Item1 == B.Item1)
{
if (A.Item2 == B.Item2)
{
if (A.Item3 == B.Item3)
{
return String.Compare(A.Item4, B.Item4);
}
return (int)(A.Item3 - B.Item3);
}
return String.Compare(A.Item2, B.Item2);
}
return String.Compare(A.Item1, B.Item1);
});
// Write out all of the file information
Console.WriteLine("Parent\t\tRom\t\tSize\t\tSHA-1");
foreach (Tuple<string, string, long, string> rom in roms)
{
Console.WriteLine(rom.Item1 + "\t" + rom.Item2 + "\t" + rom.Item3 + "\t" + rom.Item4);
}
// Now write it all out as a DAT
try
{
FileStream fs = File.Create("dirdat.xml");
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
/*
string header_old = "clrmamepro (\n" +
"\tname \"dirdat\"\n" +
"\tdescription \"dirdat\"\n" +
"\tversion \"\"\n" +
"\tcomment \"\"\n" +
"\tauthor \"DATFromDir\"\n" +
")\n";
*/
string header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!DOCTYPE datafile PUBLIC \"-//Logiqx//DTD ROM Management Datafile//EN\" \"http://www.logiqx.com/Dats/datafile.dtd\">\n\n" +
"\t<datafile>\n" +
"\t\t<header>\n" +
"\t\t\t<name>dirdat</name>\n" +
"\t\t\t<description>dirdat</description>\n" +
"\t\t\t<category>DATFromDir</category>\n" +
"\t\t\t<version></version>\n" +
"\t\t\t<date></date>\n" +
"\t\t\t<author>DATFromDir</author>\n" +
"\t\t\t<clrmamepro />\n" +
"\t\t</header>\n";
// Write the header out
sw.Write(header);
// Write out each of the machines and roms
string lastgame = "";
foreach (Tuple<string, string, long, string> rom in roms)
{
string state = "";
if (lastgame != "" && lastgame != rom.Item1)
{
state += "\t</machine>\n";
}
if (lastgame != rom.Item1)
{
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Item1) + "\">\n" +
"\t\t<description>" + HttpUtility.HtmlEncode(rom.Item1) + "</description>\n";
}
state += "\t\t<rom name=\"" + HttpUtility.HtmlEncode(rom.Item2) + "\"" +
(rom.Item3 != -1 ? " size=\"" + rom.Item3 + "\"" : "") +
(rom.Item4 != "" ? " sha1=\"" + rom.Item4.ToLowerInvariant() + "\"" : "") +
" />\n";
lastgame = rom.Item1;
sw.Write(state);
}
sw.Write("\t</machine>\n</datafile>");
Console.Write("File written!");
sw.Close();
fs.Close();
}
catch (Exception ex)
{
Console.Write(ex.ToString());
}
}
}
}

View File

@@ -0,0 +1,90 @@
<?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>..\..\Builds\</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>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<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" />
</ItemGroup>
<ItemGroup>
<Content Include="7z\7za.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\7za.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\7zxa.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\history.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\License.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\readme.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\x64\7za.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\x64\7za.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="7z\x64\7zxa.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</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

@@ -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("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

@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleGame", "SingleGame\Si
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -45,6 +47,10 @@ Global
{225A1AFD-0890-44E8-B779-7502665C23A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{225A1AFD-0890-44E8-B779-7502665C23A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{225A1AFD-0890-44E8-B779-7502665C23A5}.Release|Any CPU.Build.0 = Release|Any CPU
{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}.Release|Any CPU.ActiveCfg = Release|Any CPU
{382B75D3-079E-49D5-A830-54DD6EB5A02D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE