mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Data and Tools -> Core
This commit is contained in:
33
SabreTools.Core/BaseFirstContractResolver.cs
Normal file
33
SabreTools.Core/BaseFirstContractResolver.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace SabreTools.Core
|
||||
{
|
||||
// https://github.com/dotnet/runtime/issues/728
|
||||
public class BaseFirstContractResolver : DefaultContractResolver
|
||||
{
|
||||
public BaseFirstContractResolver()
|
||||
{
|
||||
NamingStrategy = new CamelCaseNamingStrategy();
|
||||
}
|
||||
|
||||
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
||||
{
|
||||
return base.CreateProperties(type, memberSerialization)
|
||||
.OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList();
|
||||
|
||||
IEnumerable<Type> BaseTypesAndSelf(Type t)
|
||||
{
|
||||
while (t != null)
|
||||
{
|
||||
yield return t;
|
||||
t = t.BaseType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
602
SabreTools.Core/Constants.cs
Normal file
602
SabreTools.Core/Constants.cs
Normal file
@@ -0,0 +1,602 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SabreTools.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Constants that are used throughout the library
|
||||
/// </summary>
|
||||
public static class Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// The current toolset version to be used by all child applications
|
||||
/// </summary>
|
||||
//public readonly static string Version = $"v1.0.4";
|
||||
public readonly static string Version = $"v1.0.4-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
|
||||
public const int HeaderHeight = 3;
|
||||
|
||||
#region 0-byte file constants
|
||||
|
||||
public const long SizeZero = 0;
|
||||
public const string CRCZero = "00000000";
|
||||
public static readonly byte[] CRCZeroBytes = { 0x00, 0x00, 0x00, 0x00 };
|
||||
public const string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
|
||||
public static readonly byte[] MD5ZeroBytes = { 0xd4, 0x1d, 0x8c, 0xd9,
|
||||
0x8f, 0x00, 0xb2, 0x04,
|
||||
0xe9, 0x80, 0x09, 0x98,
|
||||
0xec, 0xf8, 0x42, 0x7e };
|
||||
#if NET_FRAMEWORK
|
||||
public const string RIPEMD160Zero = "9c1185a5c5e9fc54612808977ee8f548b2258d31";
|
||||
public static readonly byte[] RIPEMD160ZeroBytes = { 0x9c, 0x11, 0x85, 0xa5,
|
||||
0xc5, 0xe9, 0xfc, 0x54,
|
||||
0x61, 0x28, 0x08, 0x97,
|
||||
0x7e, 0xe8, 0xf5, 0x48,
|
||||
0xb2, 0x25, 0x8d, 0x31 };
|
||||
#endif
|
||||
public const string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
||||
public static readonly byte[] SHA1ZeroBytes = { 0xda, 0x39, 0xa3, 0xee,
|
||||
0x5e, 0x6b, 0x4b, 0x0d,
|
||||
0x32, 0x55, 0xbf, 0xef,
|
||||
0x95, 0x60, 0x18, 0x90,
|
||||
0xaf, 0xd8, 0x07, 0x09 };
|
||||
public const string SHA256Zero = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";
|
||||
public static readonly byte[] SHA256ZeroBytes = { 0xba, 0x78, 0x16, 0xbf,
|
||||
0x8f, 0x01, 0xcf, 0xea,
|
||||
0x41, 0x41, 0x40, 0xde,
|
||||
0x5d, 0xae, 0x22, 0x23,
|
||||
0xb0, 0x03, 0x61, 0xa3,
|
||||
0x96, 0x17, 0x7a, 0x9c,
|
||||
0xb4, 0x10, 0xff, 0x61,
|
||||
0xf2, 0x00, 0x15, 0xad };
|
||||
public const string SHA384Zero = "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7";
|
||||
public static readonly byte[] SHA384ZeroBytes = { 0xcb, 0x00, 0x75, 0x3f,
|
||||
0x45, 0xa3, 0x5e, 0x8b,
|
||||
0xb5, 0xa0, 0x3d, 0x69,
|
||||
0x9a, 0xc6, 0x50, 0x07,
|
||||
0x27, 0x2c, 0x32, 0xab,
|
||||
0x0e, 0xde, 0xd1, 0x63,
|
||||
0x1a, 0x8b, 0x60, 0x5a,
|
||||
0x43, 0xff, 0x5b, 0xed,
|
||||
0x80, 0x86, 0x07, 0x2b,
|
||||
0xa1, 0xe7, 0xcc, 0x23,
|
||||
0x58, 0xba, 0xec, 0xa1,
|
||||
0x34, 0xc8, 0x25, 0xa7 };
|
||||
public const string SHA512Zero = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f";
|
||||
public static readonly byte[] SHA512ZeroBytes = { 0xdd, 0xaf, 0x35, 0xa1,
|
||||
0x93, 0x61, 0x7a, 0xba,
|
||||
0xcc, 0x41, 0x73, 0x49,
|
||||
0xae, 0x20, 0x41, 0x31,
|
||||
0x12, 0xe6, 0xfa, 0x4e,
|
||||
0x89, 0xa9, 0x7e, 0xa2,
|
||||
0x0a, 0x9e, 0xee, 0xe6,
|
||||
0x4b, 0x55, 0xd3, 0x9a,
|
||||
0x21, 0x92, 0x99, 0x2a,
|
||||
0x27, 0x4f, 0xc1, 0xa8,
|
||||
0x36, 0xba, 0x3c, 0x23,
|
||||
0xa3, 0xfe, 0xeb, 0xbd,
|
||||
0x45, 0x4d, 0x44, 0x23,
|
||||
0x64, 0x3c, 0xe8, 0x0e,
|
||||
0x2a, 0x9a, 0xc9, 0x4f,
|
||||
0xa5, 0x4c, 0xa4, 0x9f };
|
||||
public const string SpamSumZero = "QXX";
|
||||
public static readonly byte[] SpamSumZeroBytes = { 0x51, 0x58, 0x58 };
|
||||
|
||||
#endregion
|
||||
|
||||
#region Byte (1000-based) size comparisons
|
||||
|
||||
public const long KiloByte = 1000;
|
||||
public readonly static long MegaByte = (long)Math.Pow(KiloByte, 2);
|
||||
public readonly static long GigaByte = (long)Math.Pow(KiloByte, 3);
|
||||
public readonly static long TeraByte = (long)Math.Pow(KiloByte, 4);
|
||||
public readonly static long PetaByte = (long)Math.Pow(KiloByte, 5);
|
||||
public readonly static long ExaByte = (long)Math.Pow(KiloByte, 6);
|
||||
public readonly static long ZettaByte = (long)Math.Pow(KiloByte, 7);
|
||||
public readonly static long YottaByte = (long)Math.Pow(KiloByte, 8);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Byte (1024-based) size comparisons
|
||||
|
||||
public const long KibiByte = 1024;
|
||||
public readonly static long MibiByte = (long)Math.Pow(KibiByte, 2);
|
||||
public readonly static long GibiByte = (long)Math.Pow(KibiByte, 3);
|
||||
public readonly static long TibiByte = (long)Math.Pow(KibiByte, 4);
|
||||
public readonly static long PibiByte = (long)Math.Pow(KibiByte, 5);
|
||||
public readonly static long ExiByte = (long)Math.Pow(KibiByte, 6);
|
||||
public readonly static long ZittiByte = (long)Math.Pow(KibiByte, 7);
|
||||
public readonly static long YittiByte = (long)Math.Pow(KibiByte, 8);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Database schema
|
||||
|
||||
public static string HeadererFileName = Path.Combine(Globals.ExeDir, "Headerer.sqlite");
|
||||
public static string HeadererConnectionString = $"Data Source={HeadererFileName};Version = 3;";
|
||||
|
||||
#endregion
|
||||
|
||||
#region DTDs
|
||||
|
||||
public const string LogiqxDTD = @"<!--
|
||||
ROM Management Datafile - DTD
|
||||
|
||||
For further information, see: http://www.logiqx.com/
|
||||
|
||||
This DTD module is identified by the PUBLIC and SYSTEM identifiers:
|
||||
|
||||
PUBLIC string.Empty -//Logiqx//DTD ROM Management Datafile//ENstring.Empty
|
||||
SYSTEM string.Emptyhttp://www.logiqx.com/Dats/datafile.dtdstring.Empty
|
||||
|
||||
$Revision: 1.5 $
|
||||
$Date: 2008/10/28 21:39:16 $
|
||||
|
||||
-->
|
||||
|
||||
<!ELEMENT datafile(header?, game*, machine*)>
|
||||
<!ATTLIST datafile build CDATA #IMPLIED>
|
||||
<!ATTLIST datafile debug (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT header(name, description, category?, version, date?, author, email?, homepage?, url?, comment?, clrmamepro?, romcenter?)>
|
||||
<!ELEMENT name(#PCDATA)>
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
<!ELEMENT category (#PCDATA)>
|
||||
<!ELEMENT version (#PCDATA)>
|
||||
<!ELEMENT date (#PCDATA)>
|
||||
<!ELEMENT author (#PCDATA)>
|
||||
<!ELEMENT email (#PCDATA)>
|
||||
<!ELEMENT homepage (#PCDATA)>
|
||||
<!ELEMENT url (#PCDATA)>
|
||||
<!ELEMENT comment (#PCDATA)>
|
||||
<!ELEMENT clrmamepro EMPTY>
|
||||
<!ATTLIST clrmamepro header CDATA #IMPLIED>
|
||||
<!ATTLIST clrmamepro forcemerging (none|split|full) string.Emptysplitstring.Empty>
|
||||
<!ATTLIST clrmamepro forcenodump(obsolete|required|ignore) string.Emptyobsoletestring.Empty>
|
||||
<!ATTLIST clrmamepro forcepacking(zip|unzip) string.Emptyzipstring.Empty>
|
||||
<!ELEMENT romcenter EMPTY>
|
||||
<!ATTLIST romcenter plugin CDATA #IMPLIED>
|
||||
<!ATTLIST romcenter rommode (merged|split|unmerged) string.Emptysplitstring.Empty>
|
||||
<!ATTLIST romcenter biosmode(merged|split|unmerged) string.Emptysplitstring.Empty>
|
||||
<!ATTLIST romcenter samplemode(merged|unmerged) string.Emptymergedstring.Empty>
|
||||
<!ATTLIST romcenter lockrommode(yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST romcenter lockbiosmode(yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST romcenter locksamplemode(yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT game(comment*, description, year?, manufacturer?, release*, biosset*, rom*, disk*, sample*, archive*)>
|
||||
<!ATTLIST game name CDATA #REQUIRED>
|
||||
<!ATTLIST game sourcefile CDATA #IMPLIED>
|
||||
<!ATTLIST game isbios (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST game cloneof CDATA #IMPLIED>
|
||||
<!ATTLIST game romof CDATA #IMPLIED>
|
||||
<!ATTLIST game sampleof CDATA #IMPLIED>
|
||||
<!ATTLIST game board CDATA #IMPLIED>
|
||||
<!ATTLIST game rebuildto CDATA #IMPLIED>
|
||||
<!ELEMENT year (#PCDATA)>
|
||||
<!ELEMENT manufacturer (#PCDATA)>
|
||||
<!ELEMENT release EMPTY>
|
||||
<!ATTLIST release name CDATA #REQUIRED>
|
||||
<!ATTLIST release region CDATA #REQUIRED>
|
||||
<!ATTLIST release language CDATA #IMPLIED>
|
||||
<!ATTLIST release date CDATA #IMPLIED>
|
||||
<!ATTLIST release default (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT biosset EMPTY>
|
||||
<!ATTLIST biosset name CDATA #REQUIRED>
|
||||
<!ATTLIST biosset description CDATA #REQUIRED>
|
||||
<!ATTLIST biosset default (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT rom EMPTY>
|
||||
<!ATTLIST rom name CDATA #REQUIRED>
|
||||
<!ATTLIST rom size CDATA #REQUIRED>
|
||||
<!ATTLIST rom crc CDATA #IMPLIED>
|
||||
<!ATTLIST rom md5 CDATA #IMPLIED>
|
||||
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha1 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha256 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha384 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha512 CDATA #IMPLIED>
|
||||
<!ATTLIST rom merge CDATA #IMPLIED>
|
||||
<!ATTLIST rom status (baddump|nodump|good|verified) string.Emptygoodstring.Empty>
|
||||
<!ATTLIST rom date CDATA #IMPLIED>
|
||||
<!ELEMENT disk EMPTY>
|
||||
<!ATTLIST disk name CDATA #REQUIRED>
|
||||
<!ATTLIST disk md5 CDATA #IMPLIED>
|
||||
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha1 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha256 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha384 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha512 CDATA #IMPLIED>
|
||||
<!ATTLIST disk merge CDATA #IMPLIED>
|
||||
<!ATTLIST disk status (baddump|nodump|good|verified) string.Emptygoodstring.Empty>
|
||||
<!ELEMENT sample EMPTY>
|
||||
<!ATTLIST sample name CDATA #REQUIRED>
|
||||
<!ELEMENT archive EMPTY>
|
||||
<!ATTLIST archive name CDATA #REQUIRED>
|
||||
<!ELEMENT machine (comment*, description, year?, manufacturer?, release*, biosset*, rom*, disk*, sample*, archive*)>
|
||||
<!ATTLIST machine name CDATA #REQUIRED>
|
||||
<!ATTLIST machine sourcefile CDATA #IMPLIED>
|
||||
<!ATTLIST machine isbios (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST machine cloneof CDATA #IMPLIED>
|
||||
<!ATTLIST machine romof CDATA #IMPLIED>
|
||||
<!ATTLIST machine sampleof CDATA #IMPLIED>
|
||||
<!ATTLIST machine board CDATA #IMPLIED>
|
||||
<!ATTLIST machine rebuildto CDATA #IMPLIED>
|
||||
";
|
||||
public const string MAMEDTD = @"<!ELEMENT mame (machine+)>
|
||||
<!ATTLIST mame build CDATA #IMPLIED>
|
||||
<!ATTLIST mame debug (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST mame mameconfig CDATA #REQUIRED>
|
||||
<!ELEMENT machine (description, year?, manufacturer?, biosset*, rom*, disk*, device_ref*, sample*, chip*, display*, sound?, input?, dipswitch*, configuration*, port*, adjuster*, driver?, feature*, device*, slot*, softwarelist*, ramoption*)>
|
||||
<!ATTLIST machine name CDATA #REQUIRED>
|
||||
<!ATTLIST machine sourcefile CDATA #IMPLIED>
|
||||
<!ATTLIST machine isbios (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST machine isdevice (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST machine ismechanical (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST machine runnable (yes|no) string.Emptyyesstring.Empty>
|
||||
<!ATTLIST machine cloneof CDATA #IMPLIED>
|
||||
<!ATTLIST machine romof CDATA #IMPLIED>
|
||||
<!ATTLIST machine sampleof CDATA #IMPLIED>
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
<!ELEMENT year (#PCDATA)>
|
||||
<!ELEMENT manufacturer (#PCDATA)>
|
||||
<!ELEMENT biosset EMPTY>
|
||||
<!ATTLIST biosset name CDATA #REQUIRED>
|
||||
<!ATTLIST biosset description CDATA #REQUIRED>
|
||||
<!ATTLIST biosset default (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT rom EMPTY>
|
||||
<!ATTLIST rom name CDATA #REQUIRED>
|
||||
<!ATTLIST rom bios CDATA #IMPLIED>
|
||||
<!ATTLIST rom size CDATA #REQUIRED>
|
||||
<!ATTLIST rom crc CDATA #IMPLIED>
|
||||
<!ATTLIST rom md5 CDATA #IMPLIED>
|
||||
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha1 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha256 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha384 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha512 CDATA #IMPLIED>
|
||||
<!ATTLIST rom merge CDATA #IMPLIED>
|
||||
<!ATTLIST rom region CDATA #IMPLIED>
|
||||
<!ATTLIST rom offset CDATA #IMPLIED>
|
||||
<!ATTLIST rom status (baddump|nodump|good) string.Emptygoodstring.Empty>
|
||||
<!ATTLIST rom optional (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT disk EMPTY>
|
||||
<!ATTLIST disk name CDATA #REQUIRED>
|
||||
<!ATTLIST disk md5 CDATA #IMPLIED>
|
||||
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha1 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha256 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha384 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha512 CDATA #IMPLIED>
|
||||
<!ATTLIST disk merge CDATA #IMPLIED>
|
||||
<!ATTLIST disk region CDATA #IMPLIED>
|
||||
<!ATTLIST disk index CDATA #IMPLIED>
|
||||
<!ATTLIST disk writable (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST disk status (baddump|nodump|good) string.Emptygoodstring.Empty>
|
||||
<!ATTLIST disk optional (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT device_ref EMPTY>
|
||||
<!ATTLIST device_ref name CDATA #REQUIRED>
|
||||
<!ELEMENT sample EMPTY>
|
||||
<!ATTLIST sample name CDATA #REQUIRED>
|
||||
<!ELEMENT chip EMPTY>
|
||||
<!ATTLIST chip name CDATA #REQUIRED>
|
||||
<!ATTLIST chip tag CDATA #IMPLIED>
|
||||
<!ATTLIST chip type (cpu|audio) #REQUIRED>
|
||||
<!ATTLIST chip clock CDATA #IMPLIED>
|
||||
<!ELEMENT display EMPTY>
|
||||
<!ATTLIST display tag CDATA #IMPLIED>
|
||||
<!ATTLIST display type (raster|vector|lcd|svg|unknown) #REQUIRED>
|
||||
<!ATTLIST display rotate (0|90|180|270) #IMPLIED>
|
||||
<!ATTLIST display flipx (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST display width CDATA #IMPLIED>
|
||||
<!ATTLIST display height CDATA #IMPLIED>
|
||||
<!ATTLIST display refresh CDATA #REQUIRED>
|
||||
<!ATTLIST display pixclock CDATA #IMPLIED>
|
||||
<!ATTLIST display htotal CDATA #IMPLIED>
|
||||
<!ATTLIST display hbend CDATA #IMPLIED>
|
||||
<!ATTLIST display hbstart CDATA #IMPLIED>
|
||||
<!ATTLIST display vtotal CDATA #IMPLIED>
|
||||
<!ATTLIST display vbend CDATA #IMPLIED>
|
||||
<!ATTLIST display vbstart CDATA #IMPLIED>
|
||||
<!ELEMENT sound EMPTY>
|
||||
<!ATTLIST sound channels CDATA #REQUIRED>
|
||||
<!ELEMENT condition EMPTY>
|
||||
<!ATTLIST condition tag CDATA #REQUIRED>
|
||||
<!ATTLIST condition mask CDATA #REQUIRED>
|
||||
<!ATTLIST condition relation (eq|ne|gt|le|lt|ge) #REQUIRED>
|
||||
<!ATTLIST condition value CDATA #REQUIRED>
|
||||
<!ELEMENT input (control*)>
|
||||
<!ATTLIST input service (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST input tilt (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST input players CDATA #REQUIRED>
|
||||
<!ATTLIST input coins CDATA #IMPLIED>
|
||||
<!ELEMENT control EMPTY>
|
||||
<!ATTLIST control type CDATA #REQUIRED>
|
||||
<!ATTLIST control player CDATA #IMPLIED>
|
||||
<!ATTLIST control buttons CDATA #IMPLIED>
|
||||
<!ATTLIST control reqbuttons CDATA #IMPLIED>
|
||||
<!ATTLIST control minimum CDATA #IMPLIED>
|
||||
<!ATTLIST control maximum CDATA #IMPLIED>
|
||||
<!ATTLIST control sensitivity CDATA #IMPLIED>
|
||||
<!ATTLIST control keydelta CDATA #IMPLIED>
|
||||
<!ATTLIST control reverse (yes|no) string.Emptynostring.Empty>
|
||||
<!ATTLIST control ways CDATA #IMPLIED>
|
||||
<!ATTLIST control ways2 CDATA #IMPLIED>
|
||||
<!ATTLIST control ways3 CDATA #IMPLIED>
|
||||
<!ELEMENT dipswitch (condition?, diplocation*, dipvalue*)>
|
||||
<!ATTLIST dipswitch name CDATA #REQUIRED>
|
||||
<!ATTLIST dipswitch tag CDATA #REQUIRED>
|
||||
<!ATTLIST dipswitch mask CDATA #REQUIRED>
|
||||
<!ELEMENT diplocation EMPTY>
|
||||
<!ATTLIST diplocation name CDATA #REQUIRED>
|
||||
<!ATTLIST diplocation number CDATA #REQUIRED>
|
||||
<!ATTLIST diplocation inverted (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT dipvalue (condition?)>
|
||||
<!ATTLIST dipvalue name CDATA #REQUIRED>
|
||||
<!ATTLIST dipvalue value CDATA #REQUIRED>
|
||||
<!ATTLIST dipvalue default (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT configuration (condition?, conflocation*, confsetting*)>
|
||||
<!ATTLIST configuration name CDATA #REQUIRED>
|
||||
<!ATTLIST configuration tag CDATA #REQUIRED>
|
||||
<!ATTLIST configuration mask CDATA #REQUIRED>
|
||||
<!ELEMENT conflocation EMPTY>
|
||||
<!ATTLIST conflocation name CDATA #REQUIRED>
|
||||
<!ATTLIST conflocation number CDATA #REQUIRED>
|
||||
<!ATTLIST conflocation inverted (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT confsetting (condition?)>
|
||||
<!ATTLIST confsetting name CDATA #REQUIRED>
|
||||
<!ATTLIST confsetting value CDATA #REQUIRED>
|
||||
<!ATTLIST confsetting default (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT port (analog*)>
|
||||
<!ATTLIST port tag CDATA #REQUIRED>
|
||||
<!ELEMENT analog EMPTY>
|
||||
<!ATTLIST analog mask CDATA #REQUIRED>
|
||||
<!ELEMENT adjuster (condition?)>
|
||||
<!ATTLIST adjuster name CDATA #REQUIRED>
|
||||
<!ATTLIST adjuster default CDATA #REQUIRED>
|
||||
<!ELEMENT driver EMPTY>
|
||||
<!ATTLIST driver status (good|imperfect|preliminary) #REQUIRED>
|
||||
<!ATTLIST driver emulation (good|imperfect|preliminary) #REQUIRED>
|
||||
<!ATTLIST driver cocktail (good|imperfect|preliminary) #IMPLIED>
|
||||
<!ATTLIST driver savestate (supported|unsupported) #REQUIRED>
|
||||
<!ELEMENT feature EMPTY>
|
||||
<!ATTLIST feature type (protection|palette|graphics|sound|controls|keyboard|mouse|microphone|camera|disk|printer|lan|wan|timing) #REQUIRED>
|
||||
<!ATTLIST feature status (unemulated|imperfect) #IMPLIED>
|
||||
<!ATTLIST feature overall (unemulated|imperfect) #IMPLIED>
|
||||
<!ELEMENT device (instance?, extension*)>
|
||||
<!ATTLIST device type CDATA #REQUIRED>
|
||||
<!ATTLIST device tag CDATA #IMPLIED>
|
||||
<!ATTLIST device fixed_image CDATA #IMPLIED>
|
||||
<!ATTLIST device mandatory CDATA #IMPLIED>
|
||||
<!ATTLIST device interface CDATA #IMPLIED>
|
||||
<!ELEMENT instance EMPTY>
|
||||
<!ATTLIST instance name CDATA #REQUIRED>
|
||||
<!ATTLIST instance briefname CDATA #REQUIRED>
|
||||
<!ELEMENT extension EMPTY>
|
||||
<!ATTLIST extension name CDATA #REQUIRED>
|
||||
<!ELEMENT slot (slotoption*)>
|
||||
<!ATTLIST slot name CDATA #REQUIRED>
|
||||
<!ELEMENT slotoption EMPTY>
|
||||
<!ATTLIST slotoption name CDATA #REQUIRED>
|
||||
<!ATTLIST slotoption devname CDATA #REQUIRED>
|
||||
<!ATTLIST slotoption default (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT softwarelist EMPTY>
|
||||
<!ATTLIST softwarelist name CDATA #REQUIRED>
|
||||
<!ATTLIST softwarelist status (original|compatible) #REQUIRED>
|
||||
<!ATTLIST softwarelist filter CDATA #IMPLIED>
|
||||
<!ELEMENT ramoption (#PCDATA)>
|
||||
<!ATTLIST ramoption default CDATA #IMPLIED>
|
||||
";
|
||||
public const string OpenMSXDTD = @"<!ELEMENT softwaredb (person*)>
|
||||
<!ELEMENT software (title, genmsxid?, system, company,year,country,dump)>
|
||||
<!ELEMENT title (#PCDATA)>
|
||||
<!ELEMENT genmsxid (#PCDATA)>
|
||||
<!ELEMENT system (#PCDATA)>
|
||||
<!ELEMENT company (#PCDATA)>
|
||||
<!ELEMENT year (#PCDATA)>
|
||||
<!ELEMENT country (#PCDATA)>
|
||||
<!ELEMENT dump (#PCDATA)>
|
||||
";
|
||||
public const string SoftwareListDTD = @"<!ELEMENT softwarelist (software+)>
|
||||
<!ATTLIST softwarelist name CDATA #REQUIRED>
|
||||
<!ATTLIST softwarelist description CDATA #IMPLIED>
|
||||
<!ELEMENT software (description, year, publisher, info*, sharedfeat*, part*)>
|
||||
<!ATTLIST software name CDATA #REQUIRED>
|
||||
<!ATTLIST software cloneof CDATA #IMPLIED>
|
||||
<!ATTLIST software supported (yes|partial|no) string.Emptyyesstring.Empty>
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
<!ELEMENT year (#PCDATA)>
|
||||
<!ELEMENT publisher (#PCDATA)>
|
||||
<!ELEMENT info EMPTY>
|
||||
<!ATTLIST info name CDATA #REQUIRED>
|
||||
<!ATTLIST info value CDATA #IMPLIED>
|
||||
<!ELEMENT sharedfeat EMPTY>
|
||||
<!ATTLIST sharedfeat name CDATA #REQUIRED>
|
||||
<!ATTLIST sharedfeat value CDATA #IMPLIED>
|
||||
<!ELEMENT part (feature*, dataarea*, diskarea*, dipswitch*)>
|
||||
<!ATTLIST part name CDATA #REQUIRED>
|
||||
<!ATTLIST part interface CDATA #REQUIRED>
|
||||
<!-- feature is used to store things like pcb-type, mapper type, etc. Specific values depend on the system. -->
|
||||
<!ELEMENT feature EMPTY>
|
||||
<!ATTLIST feature name CDATA #REQUIRED>
|
||||
<!ATTLIST feature value CDATA #IMPLIED>
|
||||
<!ELEMENT dataarea (rom*)>
|
||||
<!ATTLIST dataarea name CDATA #REQUIRED>
|
||||
<!ATTLIST dataarea size CDATA #REQUIRED>
|
||||
<!ATTLIST dataarea width (8|16|32|64) string.Empty8string.Empty>
|
||||
<!ATTLIST dataarea endianness (big|little) string.Emptylittlestring.Empty>
|
||||
<!ELEMENT rom EMPTY>
|
||||
<!ATTLIST rom name CDATA #IMPLIED>
|
||||
<!ATTLIST rom size CDATA #IMPLIED>
|
||||
<!ATTLIST rom crc CDATA #IMPLIED>
|
||||
<!ATTLIST rom md5 CDATA #IMPLIED>
|
||||
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha1 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha256 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha384 CDATA #IMPLIED>
|
||||
<!ATTLIST rom sha512 CDATA #IMPLIED>
|
||||
<!ATTLIST rom offset CDATA #IMPLIED>
|
||||
<!ATTLIST rom value CDATA #IMPLIED>
|
||||
<!ATTLIST rom status (baddump|nodump|good) string.Emptygoodstring.Empty>
|
||||
<!ATTLIST rom loadflag (load16_byte|load16_word|load16_word_swap|load32_byte|load32_word|load32_word_swap|load32_dword|load64_word|load64_word_swap|reload|fill|continue|reload_plain|ignore) #IMPLIED>
|
||||
<!ELEMENT diskarea (disk*)>
|
||||
<!ATTLIST diskarea name CDATA #REQUIRED>
|
||||
<!ELEMENT disk EMPTY>
|
||||
<!ATTLIST disk name CDATA #REQUIRED>
|
||||
<!ATTLIST disk md5 CDATA #IMPLIED>
|
||||
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha1 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha256 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha384 CDATA #IMPLIED>
|
||||
<!ATTLIST disk sha512 CDATA #IMPLIED>
|
||||
<!ATTLIST disk status (baddump|nodump|good) string.Emptygoodstring.Empty>
|
||||
<!ATTLIST disk writeable (yes|no) string.Emptynostring.Empty>
|
||||
<!ELEMENT dipswitch (dipvalue*)>
|
||||
<!ATTLIST dipswitch name CDATA #REQUIRED>
|
||||
<!ATTLIST dipswitch tag CDATA #REQUIRED>
|
||||
<!ATTLIST dipswitch mask CDATA #REQUIRED>
|
||||
<!ELEMENT dipvalue EMPTY>
|
||||
<!ATTLIST dipvalue name CDATA #REQUIRED>
|
||||
<!ATTLIST dipvalue value CDATA #REQUIRED>
|
||||
<!ATTLIST dipvalue default (yes|no) string.Emptynostring.Empty>
|
||||
";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hash string length constants
|
||||
|
||||
public const int CRCLength = 8;
|
||||
public const int MD5Length = 32;
|
||||
#if NET_FRAMEWORK
|
||||
public const int RIPEMD160Length = 40;
|
||||
#endif
|
||||
public const int SHA1Length = 40;
|
||||
public const int SHA256Length = 64;
|
||||
public const int SHA384Length = 96;
|
||||
public const int SHA512Length = 128;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Magic numbers
|
||||
|
||||
public static readonly byte[] SevenZipSignature = { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c };
|
||||
public static readonly byte[] A7800SignatureV1 = { 0x41, 0x54, 0x41, 0x52, 0x49, 0x37, 0x38, 0x30, 0x30 }; // Offset 0x01
|
||||
public static readonly byte[] A7800SignatureV2 = { 0x41, 0x43, 0x54, 0x55, 0x41, 0x4c, 0x20, 0x43, 0x41, 0x52, 0x54, 0x20, 0x44, 0x41,
|
||||
0x54, 0x41, 0x20, 0x53, 0x54, 0x41, 0x52, 0x54, 0x53, 0x20, 0x48, 0x45, 0x52, 0x45 }; // Offset 0x64
|
||||
public static readonly byte[] AaruFormatSignature = { 0x41, 0x41, 0x52, 0x55, 0x46, 0x52, 0x4d, 0x54 };
|
||||
public static readonly byte[] BZ2Signature = { 0x42, 0x5a, 0x68 };
|
||||
public static readonly byte[] CabinetSignature = { 0x4d, 0x53, 0x43, 0x46 };
|
||||
public static readonly byte[] CHDSignature = { 0x4d, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x48, 0x44 };
|
||||
public static readonly byte[] ELFSignature = { 0x7f, 0x45, 0x4c, 0x46 };
|
||||
public static readonly byte[] FDSSignatureV1 = { 0x46, 0x44, 0x53, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
public static readonly byte[] FDSSignatureV2 = { 0x46, 0x44, 0x53, 0x1a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
public static readonly byte[] FDSSignatureV3 = { 0x46, 0x44, 0x53, 0x1a, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
public static readonly byte[] FDSSignatureV4 = { 0x46, 0x44, 0x53, 0x1a, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
public static readonly byte[] FreeArcSignature = { 0x41, 0x72, 0x43, 0x01 };
|
||||
public static readonly byte[] GzSignature = { 0x1f, 0x8b, 0x08 };
|
||||
public static readonly byte[] LRZipSignature = { 0x4c, 0x52, 0x5a, 0x49 };
|
||||
public static readonly byte[] LynxSignatureV1 = { 0x4c, 0x59, 0x4f, 0x58 };
|
||||
public static readonly byte[] LynxSignatureV2 = { 0x42, 0x53, 0x39 }; // Offset 0x06
|
||||
public static readonly byte[] LZ4Signature = { 0x18, 0x4d, 0x22, 0x04 };
|
||||
public static readonly byte[] LZ4SkippableMinSignature = { 0x18, 0x4d, 0x22, 0x04 };
|
||||
public static readonly byte[] LZ4SkippableMaxSignature = { 0x18, 0x4d, 0x2a, 0x5f };
|
||||
public static readonly byte[] N64Signature = { 0x40, 0x12, 0x37, 0x80 };
|
||||
public static readonly byte[] NESSignature = { 0x4e, 0x45, 0x53, 0x1a };
|
||||
public static readonly byte[] PCESignature = { 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb, 0x02 };
|
||||
public static readonly byte[] PESignature = { 0x4d, 0x5a };
|
||||
public static readonly byte[] PSIDSignatureV1 = { 0x50, 0x53, 0x49, 0x44, 0x00, 0x01, 0x00, 0x76 };
|
||||
public static readonly byte[] PSIDSignatureV2 = { 0x50, 0x53, 0x49, 0x44, 0x00, 0x02, 0x00, 0x7c };
|
||||
public static readonly byte[] PSIDSignatureV3 = { 0x50, 0x53, 0x49, 0x44, 0x00, 0x03, 0x00, 0x7c };
|
||||
public static readonly byte[] RarSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
|
||||
public static readonly byte[] RarFiveSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 };
|
||||
public static readonly byte[] SMCSignature = { 0xaa, 0xbb, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Offset 0x16
|
||||
public static readonly byte[] SPCSignature = { 0x53, 0x4e, 0x45, 0x53, 0x2d, 0x53, 0x50, 0x43 };
|
||||
public static readonly byte[] TarSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 };
|
||||
public static readonly byte[] TarZeroSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 };
|
||||
public static readonly byte[] UFOSignature = { 0x53, 0x55, 0x50, 0x45, 0x52, 0x55, 0x46, 0x4f }; // Offset 0x16
|
||||
public static readonly byte[] V64Signature = { 0x80, 0x37, 0x12, 0x40 };
|
||||
public static readonly byte[] XZSignature = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00 };
|
||||
public static readonly byte[] Z64Signature = { 0x37, 0x80, 0x40, 0x12 };
|
||||
public static readonly byte[] ZipSignature = { 0x50, 0x4b, 0x03, 0x04 };
|
||||
public static readonly byte[] ZipSignatureEmpty = { 0x50, 0x4b, 0x05, 0x06 };
|
||||
public static readonly byte[] ZipSignatureSpanned = { 0x50, 0x4b, 0x07, 0x08 };
|
||||
public static readonly byte[] ZPAQSignature = { 0x7a, 0x50, 0x51 };
|
||||
public static readonly byte[] ZstdSignature = { 0xfd, 0x2f, 0xb5 };
|
||||
|
||||
#endregion
|
||||
|
||||
#region Regular Expressions
|
||||
|
||||
public const string XmlPattern = @"<(.*?)>(.*?)</(.*?)>";
|
||||
public const string HeaderPatternCMP = @"(^.*?) \($";
|
||||
public const string InternalPatternCMP = @"(^\S*?) (\(.+\))$";
|
||||
public const string InternalPatternAttributesCMP = @"[^\s""]+|""[^""]*""";
|
||||
//public const string InternalPatternAttributesCMP = @"([^\s]*""[^""]+""[^\s]*)|[^""]?\w+[^""]?";
|
||||
public const string ItemPatternCMP = @"^\s*(\S*?) (.*)";
|
||||
public const string EndPatternCMP = @"^\s*\)\s*$";
|
||||
|
||||
#endregion
|
||||
|
||||
#region TorrentZip, T7z, and TGZ headers
|
||||
|
||||
/* TorrentZip Header Format
|
||||
https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE_6.2.0.txt
|
||||
http://www.romvault.com/trrntzip_explained.doc
|
||||
|
||||
00-03 Local file header signature (0x50, 0x4B, 0x03, 0x04) ZipSignature
|
||||
04-05 Version needed to extract (0x14, 0x00)
|
||||
06-07 General purpose bit flag (0x02, 0x00)
|
||||
08-09 Compression method (0x08, 0x00)
|
||||
0A-0B Last mod file time (0x00, 0xBC)
|
||||
0C-0D Last mod file date (0x98, 0x21)
|
||||
*/
|
||||
public readonly static byte[] TorrentZipHeader = new byte[] { 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0xbc, 0x98, 0x21 };
|
||||
|
||||
/* Torrent7z Header Format
|
||||
http://cpansearch.perl.org/src/BJOERN/Compress-Deflate7-1.0/7zip/DOC/7zFormat.txt
|
||||
|
||||
00-05 Local file header signature (0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C) SevenZipSignature
|
||||
06-07 ArchiveVersion (0x00, 0x03)
|
||||
The rest is unknown
|
||||
*/
|
||||
public readonly static byte[] Torrent7ZipHeader = new byte[] { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c, 0x00, 0x03 };
|
||||
public readonly static byte[] Torrent7ZipSignature = new byte[] { 0xa9, 0xa9, 0x9f, 0xd1, 0x57, 0x08, 0xa9, 0xd7, 0xea, 0x29, 0x64, 0xb2,
|
||||
0x36, 0x1b, 0x83, 0x52, 0x33, 0x00, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x37, 0x7a, 0x5f, 0x30, 0x2e, 0x39, 0x62, 0x65, 0x74, 0x61 };
|
||||
|
||||
/* (Torrent)GZ Header Format
|
||||
https://tools.ietf.org/html/rfc1952
|
||||
|
||||
00-01 Identification (0x1F, 0x8B) GzSignature
|
||||
02 Compression Method (0-7 reserved, 8 deflate; 0x08)
|
||||
03 Flags (0 FTEXT, 1 FHCRC, 2 FEXTRA, 3 FNAME, 4 FCOMMENT, 5 reserved, 6 reserved, 7 reserved; 0x04)
|
||||
04-07 Modification time (Unix format; 0x00, 0x00, 0x00, 0x00)
|
||||
08 Extra Flags (2 maximum compression, 4 fastest algorithm; 0x00)
|
||||
09 OS (See list on https://tools.ietf.org/html/rfc1952; 0x00)
|
||||
0A-0B Length of extra field (mirrored; 0x1C, 0x00)
|
||||
0C-27 Extra field
|
||||
0C-1B MD5 Hash
|
||||
1C-1F CRC hash
|
||||
20-27 Int64 size (mirrored)
|
||||
*/
|
||||
public readonly static byte[] TorrentGZHeader = new byte[] { 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00 };
|
||||
|
||||
/* (Torrent)XZ Header Format
|
||||
https://tukaani.org/xz/xz-file-format.txt
|
||||
|
||||
00-05 Identification (0xFD, '7', 'z', 'X', 'Z', 0x00) XzSignature
|
||||
06 Flags (0x01 - CRC32, 0x04 - CRC64, 0x0A - SHA-256)
|
||||
07-0A Flags CRC32 (uint, little-endian)
|
||||
*/
|
||||
public readonly static byte[] TorrentXZHeader = new byte[] { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x01, 0x69, 0x22, 0xde, 0x36 };
|
||||
|
||||
#endregion
|
||||
|
||||
#region ZIP internal signatures
|
||||
|
||||
public const uint LocalFileHeaderSignature = 0x04034b50;
|
||||
public const uint EndOfLocalFileHeaderSignature = 0x08074b50;
|
||||
public const uint CentralDirectoryHeaderSignature = 0x02014b50;
|
||||
public const uint EndOfCentralDirSignature = 0x06054b50;
|
||||
public const uint Zip64EndOfCentralDirSignature = 0x06064b50;
|
||||
public const uint Zip64EndOfCentralDirectoryLocator = 0x07064b50;
|
||||
public const uint TorrentZipFileDateTime = 0x2198BC00;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3407
SabreTools.Core/Converters.cs
Normal file
3407
SabreTools.Core/Converters.cs
Normal file
File diff suppressed because it is too large
Load Diff
2353
SabreTools.Core/Enums.cs
Normal file
2353
SabreTools.Core/Enums.cs
Normal file
File diff suppressed because it is too large
Load Diff
50
SabreTools.Core/Globals.cs
Normal file
50
SabreTools.Core/Globals.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SabreTools.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Globally-accessible objects for the library
|
||||
/// </summary>
|
||||
public class Globals
|
||||
{
|
||||
#region Public accessors
|
||||
|
||||
/// <summary>
|
||||
/// Command line arguments passed in to the parent program
|
||||
/// </summary>
|
||||
public static string CommandLineArgs => string.Join(" ", Environment.GetCommandLineArgs());
|
||||
|
||||
/// <summary>
|
||||
/// Directory path for the current executable
|
||||
/// </summary>
|
||||
public static string ExeDir => Path.GetDirectoryName(ExeName);
|
||||
|
||||
/// <summary>
|
||||
/// File path for the current executable
|
||||
/// </summary>
|
||||
public static string ExeName => new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum threads to use during parallel operations
|
||||
/// </summary>
|
||||
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
|
||||
|
||||
/// <summary>
|
||||
/// ParallelOptions object for use in parallel operations
|
||||
/// </summary>
|
||||
public static ParallelOptions ParallelOptions => new ParallelOptions()
|
||||
{
|
||||
MaxDegreeOfParallelism = MaxThreads
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Temporary directory location
|
||||
/// </summary>
|
||||
public static string TempDir { get; set; } = Path.GetTempPath();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
674
SabreTools.Core/Licenses/LICENSE
Normal file
674
SabreTools.Core/Licenses/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
21
SabreTools.Core/Licenses/LICENSE.sharpcompress.txt
Normal file
21
SabreTools.Core/Licenses/LICENSE.sharpcompress.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Adam Hathcock
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
69
SabreTools.Core/Prepare.cs
Normal file
69
SabreTools.Core/Prepare.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic console preparation for program output
|
||||
/// </summary>
|
||||
public static class Prepare
|
||||
{
|
||||
/// <summary>
|
||||
/// Readies the console and outputs the header
|
||||
/// </summary>
|
||||
/// <param name="program">The name to be displayed as the program</param>
|
||||
public static void SetConsoleHeader(string program)
|
||||
{
|
||||
// Dynamically create the header string, adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string
|
||||
int width = Console.WindowWidth - 3;
|
||||
string border = $"+{new string('-', width)}+";
|
||||
string mid = $"{program} {Constants.Version}";
|
||||
mid = $"|{mid.PadLeft(((width - mid.Length) / 2) + mid.Length).PadRight(width)}|";
|
||||
|
||||
// If we're outputting to console, do fancy things
|
||||
if (!Console.IsOutputRedirected)
|
||||
{
|
||||
// Set the console to ready state
|
||||
ConsoleColor formertext = ConsoleColor.White;
|
||||
ConsoleColor formerback = ConsoleColor.Black;
|
||||
if (!MonoOrCoreEnvironment)
|
||||
{
|
||||
Console.SetBufferSize(Console.BufferWidth, 999);
|
||||
formertext = Console.ForegroundColor;
|
||||
formerback = Console.BackgroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.BackgroundColor = ConsoleColor.Blue;
|
||||
}
|
||||
|
||||
Console.Title = $"{program} {Constants.Version}";
|
||||
|
||||
// Output the header
|
||||
Console.WriteLine(border);
|
||||
Console.WriteLine(mid);
|
||||
Console.WriteLine(border);
|
||||
Console.WriteLine();
|
||||
|
||||
// Return the console to the original text and background colors
|
||||
if (!MonoOrCoreEnvironment)
|
||||
{
|
||||
Console.ForegroundColor = formertext;
|
||||
Console.BackgroundColor = formerback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if running in a Mono or .NET Core environment
|
||||
/// </summary>
|
||||
private static bool MonoOrCoreEnvironment
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET_FRAMEWORK
|
||||
return Type.GetType("Mono.Runtime") != null;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1475
SabreTools.Core/README.1ST
Normal file
1475
SabreTools.Core/README.1ST
Normal file
File diff suppressed because it is too large
Load Diff
682
SabreTools.Core/README.DEPRECIATED
Normal file
682
SabreTools.Core/README.DEPRECIATED
Normal file
@@ -0,0 +1,682 @@
|
||||
Removed Commands
|
||||
|
||||
In this section, there is a list of commands that have been retired and will no longer work.
|
||||
One thing to note is that not all commands will have a full description and are often copied
|
||||
from the original help text from the program. Also worth noting is that some of them were used
|
||||
in conjuction with other flags that may still exist and are thus not listed below.
|
||||
|
||||
Below are originally from DATabaseTwo (Standalone) -
|
||||
|
||||
-h, -?, --help Show this help dialog
|
||||
-g, --generate Start tool in generate mode
|
||||
-ga, --generate-all Start tool in generate all mode
|
||||
-i, --ignore Don't prompt for new sources
|
||||
-lsy, --list-systems List all systems (id <= name)
|
||||
-nr, --no-rename Don't auto-rename games by source/system
|
||||
-o, --old Output DAT in CMP format instead of XML
|
||||
-sys=, --system= System ID to generate from
|
||||
|
||||
Below are originally from DATFromDir (Standalone) -
|
||||
|
||||
-h, -?, --help Show this help dialog
|
||||
-m, --noMD5 Don't include MD5 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
|
||||
-o, --old Output DAT in CMP format instead of XML
|
||||
-gz, --gz-files Allow reading of GZIP files as archives
|
||||
-ro, --romba Read files from a Romba input
|
||||
-n=, --name= Set the internal name of the DAT
|
||||
-d=, --desc= Set the filename and 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
|
||||
-t=, --temp= Set the temporary directory to use
|
||||
|
||||
Below are originally from DatToMiss (Standalone) -
|
||||
|
||||
-h, -?, --help Show this help dialog
|
||||
-l, --log Enable log to file
|
||||
-r, --roms Output roms to miss instead of sets
|
||||
-pre=, --prefix= Set prefix to be printed in front of all lines
|
||||
-post=, --postfix= Set postfix to be printed behind all lines
|
||||
|
||||
Below are originally from Filter (Standalone) -
|
||||
|
||||
-h, -?, --help Show this help dialog
|
||||
-out=, --out= Output directory
|
||||
-gn=, --game-name= Game name to be filtered on
|
||||
-rn=, --rom-name= Rom name to be filtered on
|
||||
-rt=, --rom-type= Rom type to be filtered on
|
||||
-sgt=, --greater= Size greater than or equal to
|
||||
-slt=, --less= Size less than or equal to
|
||||
-seq=, --equal= Size equal to
|
||||
-crc=, --crc= CRC to be filtered on
|
||||
-md5=, --md5= MD5 to be filtered on
|
||||
-sha1=, --sha1= SHA-1 to be filtered on
|
||||
-nd, --nodump Only match nodump roms
|
||||
-nnd, --not-nodump Exclude all nodump roms
|
||||
|
||||
Game name, Rom name, CRC, MD5, SHA-1 can 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'
|
||||
|
||||
Below are originally from HashSplit (Standalone) -
|
||||
|
||||
-h, -?, --help Show this help dialog
|
||||
-out= Output directory
|
||||
|
||||
Below are originally from Headerer (Standalone) -
|
||||
|
||||
-?, -h, -help Show the built-in help text
|
||||
Built-in to most of the programs is a basic help text
|
||||
|
||||
-e, -extract Enable detect and remove mode
|
||||
This mode allows the user to detect, store, and remove copier headers from a file
|
||||
or folder of files. The headers are backed up and collated by the hash of the un-
|
||||
headered file. Files are then output without the detected copier header alongside
|
||||
the originals with the suffix .new. No input files are altered in the process.
|
||||
|
||||
-r, -restore Restore headers to file(s)
|
||||
This mode uses stored copier headers and reapplies them to files if they match the
|
||||
included hash. More than one header can be applied to a file, so they will be out-
|
||||
put to new files, suffixed with .newX, where X is a number. No input files are
|
||||
altered in the process.
|
||||
|
||||
Below are originally from MergeDAT / DiffDat (Standalone) -
|
||||
|
||||
-h, -?, --help Show this help dialog
|
||||
-l, --log Enable log to file
|
||||
-d, --diff Switch to diffdat mode
|
||||
-di, --diff Switch to diffdat mode
|
||||
-m, --merge Enable deduping in the created DAT
|
||||
-dd, --dedup Enable deduping in the created DAT
|
||||
-b, --bare Don't include date in file name
|
||||
-u, --unzip Force unzipping in created DAT
|
||||
-o, --old Output DAT in CMP format instead of XML
|
||||
-n=, --name= Set the 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
|
||||
-a=, --author= Set the author of the DAT");
|
||||
|
||||
Below are originally from OfflineMerge (Standalone) -
|
||||
|
||||
-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
|
||||
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");
|
||||
|
||||
Below are originally from SabreTools / DATabase -
|
||||
|
||||
-a, --add Add a new system or source to the database
|
||||
Add a new system or source to the DAT database, including additional information.
|
||||
|
||||
manu= Manufacturer name (system only)
|
||||
system= System name (system only)
|
||||
source= Source name (source only)
|
||||
url= URL (source only)
|
||||
|
||||
-manu= Manufacturer name
|
||||
Used only when adding a system to the database
|
||||
|
||||
-system= System name
|
||||
Used only when adding a system to the database
|
||||
|
||||
-source= Source name
|
||||
Used only when adding a source to the database
|
||||
|
||||
-url= Source URL
|
||||
Used only when adding a source to the database
|
||||
|
||||
-ad, --all-diff Enable output of all diff variants
|
||||
|
||||
-c=, --cat= Set the category of the DAT
|
||||
|
||||
-cc, --convert-cmp Convert any DAT to CMP
|
||||
-clean Clean game names according to WoD standards
|
||||
-out= Output directory
|
||||
out= Output directory
|
||||
|
||||
-cf, --copy-files Copy files to the temp directory before parsing
|
||||
If this flag is set, then all files that are going to be parsed are
|
||||
moved to the temporary directory before being hashed. This can be
|
||||
helpful in cases where the temp folder is located on an SSD and the
|
||||
user wants to take advantage of this.
|
||||
|
||||
-cv, --convert Enable conversion of input files to unarchived folders
|
||||
Using a folder or set of folders, rebuild to another folder.
|
||||
|
||||
-dat= Name of the DAT to be used as a filter
|
||||
A supplied DAT file to be used as a filter in conversion. If a file is found in the
|
||||
DAT, it will be skipped on output. This allows convert to act like an anti-sort,
|
||||
useful for finding useless files in an input folder.
|
||||
|
||||
-out= Set the name of the output directory
|
||||
This sets an output folder to be used when the files are created. If a path
|
||||
is not defined, the application directory is used instead.
|
||||
|
||||
-t=, --temp= Set the name of the temporary directory
|
||||
Optionally, a temp folder can be supplied in the case the default temp directory
|
||||
(inside the running folder) is not preferred. This is used for any operations
|
||||
that require an archive to be extracted.
|
||||
|
||||
-del, --delete Delete input files
|
||||
This is a WIP flag that allows for deletion of input files once they have been
|
||||
rebuilt. It is not recommended for normal use because it does not discriminate
|
||||
whether or not the input files were rebuilt or not before deletion
|
||||
|
||||
-t7z Enable Torrent 7zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent7Zip (T7Z)
|
||||
files. This format is based on the LZMA container format 7zip, but with custom header
|
||||
information. This is currently unused by any major application.
|
||||
|
||||
-tar Enable Tape ARchive output [NOT IMPLEMENTED]
|
||||
Instead of outputting the fiels to folder, files will be rebuilt to Tape ARchive (TAR)
|
||||
files. This format is a standardized storage archive without any compression, usually
|
||||
used with other compression formats around it. It is widely used in backup applications
|
||||
and source code archives.
|
||||
|
||||
-tgz Enable Torrent GZ output
|
||||
Instead of outputting the files to folder, files will be rebuilt to TorrentGZ (TGZ)
|
||||
files. This format is based on the GZip archive format, but with custom header
|
||||
information and a file name replaced by the SHA-1 of the file inside. This is
|
||||
primarily used by external tool Romba (https://github.com/uwedeportivo/romba), but
|
||||
may be used more widely in the future.
|
||||
|
||||
-r, --romba Enable Romba depot directory output
|
||||
As an extension of the parent flag, this outputs the TGZ files into directories
|
||||
based on the structure used by Romba. This uses nested folders using the first
|
||||
4 bytes of the SHA-1, 1 byte for each layer of the directory name. It also
|
||||
includes two auxilary files, .romba_size and .romba_size.backup, that have the
|
||||
compressed size of the folder inside for use with Romba.
|
||||
|
||||
-tlrz Enable Torrent Long-Range Zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent Long-Range
|
||||
Zip (TLRZ) files. This format is based on the LRZip file format as defined at
|
||||
https://github.com/ckolivas/lrzip but with custom header information. This is currently
|
||||
unused by any major application.
|
||||
|
||||
-trar Enable Torrent RAR output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent RAR (TRAR)
|
||||
files. This format is based on the RAR propietary format but with custom header
|
||||
information. This is currently unused by any major application;
|
||||
|
||||
-txz Enable Torrent XZ output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent XZ (TXZ) files.
|
||||
This format is based on the LZMA container format XZ, but with custom header
|
||||
information. This is currently unused by any major application;
|
||||
|
||||
-tzip Enable Torrent Zip output
|
||||
Instead of ouputting files to folder, files will be rebuilt to TorrentZip (TZ) files.
|
||||
This format is based on the ZIP archive format, but with custom header information.
|
||||
This is primarily used by external tool RomVault (http://www.romvault.com/) and is
|
||||
already widely used.
|
||||
|
||||
-7z={0} Set scanning level for 7z archives
|
||||
-gz={2} Set scanning level for GZip archives
|
||||
-rar={2} Set scanning level for RAR archives
|
||||
-zip={0} Set scanning level for ZIP archives
|
||||
For each of the major archive types recognized by the libraries used by this
|
||||
program, scan the archive in one of the following ways:
|
||||
0 Hash both archive and its contents
|
||||
1 Only hash contents of the archive
|
||||
2 Only hash archive itself (treat like a regular file)
|
||||
|
||||
-cm, --convert-miss Convert from DAT to miss
|
||||
-r, --roms Output roms to miss instead of sets
|
||||
-gp, --game-prefix Add game name as a prefix to each item
|
||||
-pre=, --prefix= Set prefix to be printed in front of all lines
|
||||
-post=, --postfix= Set postfix to be printed behind 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
|
||||
-ro, --romba Output roms in Romba format (requires SHA-1)
|
||||
-tsv, --tsv Output roms in Tab-Separated Value format
|
||||
-cs, --convert-sd Convert any DAT to SabreDAT
|
||||
-clean Clean game names according to WoD standards
|
||||
-out= Output directory
|
||||
-cr, --convert-rc Convert any DAT to RomCenter
|
||||
-clean Clean game names according to WoD standards
|
||||
-out= Output directory
|
||||
-cr, --convert-rv Convert an XML DAT to RV
|
||||
out= Output directory
|
||||
-cx, --convert-xml Convert a RV DAT to XML
|
||||
out= Output directory
|
||||
-cx, --convert-xml Convert any DAT to XML
|
||||
-clean Clean game names according to WoD standards
|
||||
-out= Output directory
|
||||
out= Output directory
|
||||
|
||||
-d=, --desc= Set the description of the DAT
|
||||
Set the description for the output DAT(s) [default is the folder name]
|
||||
|
||||
-dp, -dfdp Create a DAT from each input directory using parallel code
|
||||
Create a DAT file from an input directory or set of files. By default, this will
|
||||
output a DAT named based on the input directory and the current date. It will also
|
||||
treat all archives as possible games and add all three hashes for each file.
|
||||
|
||||
-nm, -noMD5 Don't include MD5 in output
|
||||
This allows the user to skip calculating the MD5 for each of the files which will
|
||||
speed up the creation of the DAT.
|
||||
|
||||
-ns, -noSHA1 Don't include SHA1 in output
|
||||
This allows the user to skip calculating the SHA-1 for each of the files which will
|
||||
speed up the creation of the DAT.
|
||||
|
||||
-b, -bare Don't include date in file name
|
||||
Normally, the DAT will be created with the date in the file name. This flag removes
|
||||
that but keeps the date tag intact.
|
||||
|
||||
-u, -unzip Force unzipping in created DAT
|
||||
This sets the 'forcepacking="unzip"' flag in the outputted DAT. When used with a
|
||||
file manager that allows for it, this will force the outputted files to be in
|
||||
subdirectories instead of archives.
|
||||
|
||||
-f, -files Treat archives as files
|
||||
Instead of trying to enumerate the files within archives, treat the archives as
|
||||
files themselves. This is good for uncompressed sets that include archives that
|
||||
should be read as-is.
|
||||
|
||||
-oc, --output-cmp Output in CMP format
|
||||
Add outputting the created DAT to clrmamepro format
|
||||
|
||||
-om, --output-miss Output in Missfile format
|
||||
Add outputting the created DAT to GoodTools miss format
|
||||
|
||||
-omd5, --output-md5 Output in MD5 format
|
||||
Add outputting the created DAT to MD5 format
|
||||
|
||||
-or, --output-rc Output in RomCenter format
|
||||
Add outputting the created DAT to RomCenter format
|
||||
|
||||
-os, --output-sd Output in SabreDAT format
|
||||
Add outputting the created DAT to SabreDAT XML format
|
||||
|
||||
-osfv, --output-sfv Output in SFV format
|
||||
Add outputting the created DAT to SFV format
|
||||
|
||||
-osha1, -output-sha1 Output in SHA-1 format
|
||||
Add outputting the created DAT to SHA1 format
|
||||
|
||||
-ox, -output-xml Output in Logiqx XML format (default)
|
||||
Add outputting the created DAT to Logiqx XML format
|
||||
|
||||
-gz, -gz-files Allow reading of GZIP files as archives
|
||||
Since GZip files are not commonly used for file storage, this flag allows for
|
||||
any GZip archives to have their contents hashed instead.
|
||||
|
||||
-ro, -romba Read files from a Romba input
|
||||
Allow for reading of GZipped files as if they were from a Romba depot. This
|
||||
implies that the files will be in the TorrentGZ format as well, including
|
||||
naming convention.
|
||||
|
||||
-f=, -filename= Set the external name of the DAT
|
||||
Set the base filename for the output DAT(s) [default is folder name plus date]
|
||||
|
||||
-n=, -name= Set the internal name of the DAT
|
||||
Set the internal name for the output DAT(s) [default is folder name plus date]
|
||||
|
||||
-de=, -desc= Set the description of the DAT
|
||||
Set the description for the output DAT(s) [default is the folder name]
|
||||
|
||||
-c=, -cat= Set the category of the DAT
|
||||
Set the category for the output DAT(s) [default is blank]
|
||||
|
||||
-v=, -version= Set the version of the DAT
|
||||
Set the version for the output DAT(s) [default is blank]
|
||||
|
||||
-au=, -author= Set the author of the DAT
|
||||
Set the author for the output DAT(s) [default is blank]
|
||||
|
||||
-sd, -superdat Enable SuperDAT creation
|
||||
Set the type flag to "SuperDAT" for the output DAT as well as preserving the
|
||||
directory structure of the inputted folder, if applicable
|
||||
|
||||
-t=, -temp= Set the name of the temporary directory
|
||||
Optionally, a temp folder can be supplied in the case the default temp directory
|
||||
(inside the running folder) is not preferred. This is used for any operations
|
||||
that require an archive to be extracted.
|
||||
|
||||
-mt={4} Amount of threads to use
|
||||
Optionally, set the number of threads to use for the multithreaded operations.
|
||||
The default is 4 threads; -1 means unlimited threads created.
|
||||
|
||||
exta= First extension to split by
|
||||
extb= Second extension to split by
|
||||
|
||||
-f, --filter Filter DATs by inputted criteria
|
||||
-out=, --out= Output directory
|
||||
-gn=, --game-name= Game name to be filtered on
|
||||
-rn=, --rom-name= Rom name to be filtered on
|
||||
-rt=, --rom-type= Rom type to be filtered on
|
||||
-sgt=, --greater= Size greater than or equal to
|
||||
-slt=, --less= Size less than or equal to
|
||||
-seq=, --equal= Size equal to
|
||||
-crc=, --crc= CRC to be filtered on
|
||||
-md5=, --md5= MD5 to be filtered on
|
||||
-sha1=, --sha1= SHA-1 to be filtered on
|
||||
-nd, --nodump Only match nodump roms
|
||||
-nnd, --not-nodump Exclude all nodump roms
|
||||
|
||||
-g, -generate Start tool in generate mode
|
||||
This starts the tool in DATabase generate mode. This will allow for creation of
|
||||
managed DATs based on the inputted systems and sources as defined by other flags.
|
||||
|
||||
-system= Comma-separated list of system IDs
|
||||
-source= Comma-separated list of source IDs
|
||||
-out= Output directory
|
||||
|
||||
-system= System ID to generate from
|
||||
Set the system ID to be used to create an output DAT
|
||||
|
||||
-nr, -no-rename Don't auto-rename games
|
||||
By default, games are automatically renamed with the source (for system-derived
|
||||
DATs), system (for source-derived DATs), or both (for the complete merged DAT).
|
||||
This flag disables the automatic renaming and uses the game names as they are.
|
||||
|
||||
-o, -old Output DAT in CMP format instead of XML
|
||||
As a holdover from only two output formats, this tool defaults to Logiqx XML
|
||||
DAT outputs. If this flag is enabled, a clrmamepro DAT will be created instead.
|
||||
|
||||
-ga, -generate-all Start tool in generate all mode
|
||||
This starts the tool in DATabase generate all mode. This will allow for creation of
|
||||
managed DATs based on the entire DAT folder.
|
||||
|
||||
-nr, -no-rename Don't auto-rename games
|
||||
By default, games are automatically renamed with the source (for system-derived
|
||||
DATs), system (for source-derived DATs), or both (for the complete merged DAT).
|
||||
This flag disables the automatic renaming and uses the game names as they are.
|
||||
|
||||
-o, -old Output DAT in CMP format instead of XML
|
||||
As a holdover from only two output formats, this tool defaults to Logiqx XML
|
||||
DAT outputs. If this flag is enabled, a clrmamepro DAT will be created instead.
|
||||
|
||||
-old, --romvault Produce a DAT in RV format
|
||||
|
||||
-hd, --headerer Backup or restore copier headers from a variety of file types
|
||||
Headerer is meant as an intermediary between header skipper files (which, a bit
|
||||
apart from their name, do not just show how to skip copier headers) and rom managers
|
||||
that do not use them.
|
||||
|
||||
By default, this will detect, store, and remove copier headers from a file or folder
|
||||
of files. The headers are backed up and collated by the hash of the unheadered file.
|
||||
Files are then output without the detected copier header alongside the originals with
|
||||
the suffix .new. No input files are altered in the process.
|
||||
|
||||
The following systems have headers that this program can work with:
|
||||
- Atari 7800
|
||||
- Atari Lynx
|
||||
- Commodore PSID Music
|
||||
- NEC PC-Engine / TurboGrafx 16
|
||||
- Nintendo Famicom / Nintendo Entertainment System
|
||||
- Nintendo Famicom Disk System
|
||||
- Nintendo Super Famicom / Super Nintendo Entertainment System
|
||||
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC Music
|
||||
|
||||
-re, --restore Restore headers to file(s)
|
||||
Instead of the default extraction, this flag enables use of stored copier headers
|
||||
to reapply them to files if they match the included hash. More than one header can
|
||||
be applied to a file, so they will be output to new files, suffixed with .newX,
|
||||
where X is a number. No input files are altered in the process.
|
||||
|
||||
-out= Set the name of the output directory
|
||||
This sets an output folder to be used when the files are created. If a path
|
||||
is not defined, the application directory is used instead.
|
||||
|
||||
-i, -import Start tool in import mode
|
||||
This starts the tool in DATabase import mode. This will allow for hashing of new
|
||||
DAT files in the dats folder. If a source for the DAT cannot be automatically
|
||||
determined, the user will be promted to select a source or enter a new one.
|
||||
|
||||
-ig, -ignore Don't prompt for new sources
|
||||
If a source cannot be determined, then use the "Default" source instead of
|
||||
asking the user.
|
||||
|
||||
-l, --log Enable logging of program output
|
||||
|
||||
-lso, -list-sources List all sources (id <= name)
|
||||
List all sources in the database, ordered by the internal ID and mapped to the name
|
||||
|
||||
-lsy, -list-systems List all systems (id <= name)
|
||||
List all systems in the database, ordered by the internal ID and mapped to the name
|
||||
|
||||
-nd, --nodump Include only match nodump roms
|
||||
-nnd, --not-nodump Exclude all nodump roms
|
||||
These flags allow for filtering based on the nodump status in the source DAT(s)
|
||||
|
||||
-ol, --offmerge Update DATS for offline arrays
|
||||
This is a power user tool for dealing with offline arrays, specifically creating
|
||||
have and miss lists without having to reconnect drives.
|
||||
|
||||
This option will output the following DATs based on the inputs as defined below:
|
||||
(a) Net New = (New Complete)-(Current Complete)
|
||||
(b) Unneeded (Current Complete)-(New Complete)
|
||||
(c) New Missing (Net New)+(Current Missing-(Unneeded))
|
||||
(d) Have (New Complete)-(New Missing)
|
||||
OR (Complete or NewComplete) (Missing) if one is missing
|
||||
|
||||
-com= Complete current DAT
|
||||
This is a merged and deduped DAT that includes all DATs that should be checked
|
||||
|
||||
-fix= Complete current Missing
|
||||
This is a merged and deduped DAT that includes all fixdats representing missing
|
||||
files
|
||||
|
||||
-new= New Complete DAT
|
||||
This is a merged and deduped DAT that includes all current and updated DATs that
|
||||
should be checked
|
||||
|
||||
-fk, -fake Replace all hashes and sizes by the default
|
||||
For further offline management, this option will replace all hashes in the output
|
||||
DATs to be their 0-byte equivalents. This allows for file managers to be used
|
||||
to still deal with the DATs without reconnecting the drives
|
||||
|
||||
out= Output directory
|
||||
|
||||
-rm, -remove Remove a system or source from the database
|
||||
Remove a system or source to the DAT database so it can no longer be used
|
||||
|
||||
-system= System ID
|
||||
Internal ID of the system to be removed
|
||||
|
||||
-source= Source ID
|
||||
Internal ID of the source to be removed
|
||||
|
||||
system= Comma-separated list of system IDs
|
||||
source= Comma-separated list of source IDs
|
||||
|
||||
(-ss, --sort - This feature flag is not removed, just internal flags)
|
||||
-7z=, --7z= Set scanning level for 7zip archives (default 1)
|
||||
-gz=, --gz= Set scanning level for GZip archives (default 1)
|
||||
-rar=, --rar= Set scanning level for RAR archives (default 1)
|
||||
-zip=, --zip= Set scanning level for Zip archives (default 1)
|
||||
Scan archives in one of the following ways:
|
||||
0 - Hash both archive and its contents
|
||||
1 - Only hash contents of the archive
|
||||
2 - Only hash archive itself (treat like a regular file)
|
||||
|
||||
-sa, --scan-all Set scanning levels for all archives to 0
|
||||
This flag is the short equivalent to -7z=0 -gz=0 -rar=0 -zip=0
|
||||
wrapped up. Generally this will be helpful in all cases where the
|
||||
content of the rebuild folder is not entirely known or is known to be
|
||||
mixed.
|
||||
|
||||
-tm, --trim-merge Consolidate DAT into a single game and trim entries
|
||||
In the cases where files will have too long a name, this allows for trimming
|
||||
the name of the files to the NTFS maximum length at most
|
||||
|
||||
-rd=, --root-dir= Set the root directory for trimming calculation
|
||||
In the case that the files will not be stored from the root directory,
|
||||
a new root can be set for path length calculations
|
||||
|
||||
-nr, --no-rename Keep game names instead of using '!'
|
||||
By default, this will rename games to a single "!" character. This flag enables
|
||||
the original game names to be kept
|
||||
|
||||
-df, --disable-force Disable forceunzipping
|
||||
By default, this will set the forcepacking="unzip" flag on the output DAT. This
|
||||
flag disables this output
|
||||
|
||||
-u, --unzip Force unzipping in created DAT
|
||||
This sets the 'forcepacking="unzip"' flag in the outputted DAT. When used with a
|
||||
file manager that allows for it, this will force the outputted files to be in
|
||||
subdirectories instead of archives.
|
||||
|
||||
Below are originally from SimpleSort (Standalone) -
|
||||
|
||||
-?, -h, --help Show the built-in help text
|
||||
Built-in to most of the programs is a basic help text
|
||||
|
||||
-dat= Name of the DAT to be used for the various options
|
||||
This DAT file is required for everything that SimpleSort currently does, so not
|
||||
supplying one will result in an error. Depending on the additional flags that are
|
||||
supplied, the DAT will be used differently, as described below. By default, the
|
||||
DAT is used to check which files need to be rebuilt.
|
||||
|
||||
-out= Set the name of the output directory
|
||||
This sets an output folder to be used by various parts of the program. As with the
|
||||
DAT file, this input is used differently based on the flags that are supplied. By
|
||||
default, the output folder is used as the target to rebuild files to.
|
||||
|
||||
-t=, --temp= Set the name of the temporary directory
|
||||
Optionally, a temp folder can be supplied in the case the default temp directory
|
||||
(inside the running folder) is not preferred. This is used for any operations that
|
||||
require an archive to be extracted.
|
||||
|
||||
-d, --delete Enable deletion of the input files
|
||||
Optionally, the input files, once processed, can be deleted. This can be useful
|
||||
when the original file structure is no longer needed or if there is limited space
|
||||
on the source drive.
|
||||
|
||||
-qs, --quick Enable quick scanning of archives
|
||||
For all archives, if this flag is enabled, it will only use the header information
|
||||
to get the archive entries' file information. The upside to this is that it is much
|
||||
quicker than extracting all files to the temp folder. On the downside, it can only
|
||||
get the CRC and size from most archive formats, leading to possible issues.
|
||||
|
||||
-ad, --add-date Write dates for each file parsed, if available
|
||||
If this flag is set, the the date in the DAT will be used for the output file
|
||||
instead of the standard date and time for TorrentZip. This will technically
|
||||
invalidate the output files as proper TorrentZip files because the date will not
|
||||
match the standard.
|
||||
|
||||
-v, --verify Enable verification of output directory
|
||||
This overrides the default rebuilding and only requires the DAT and the output folder.
|
||||
Here, the DAT is used to verify the output directory directly and then output a
|
||||
simple FixDAT. This can be misleading, currently, because it only checks for exact
|
||||
matches.
|
||||
|
||||
-c, --convert Enable filtering by input DAT
|
||||
This overrides the default rebuilding by using the DAT as a filter of what not to
|
||||
output. If no DAT is supplied, the entire input folder will be rebuild file-by-file
|
||||
to the output folder.
|
||||
|
||||
-tgz Enable Torrent GZ output
|
||||
Instead of outputting the files to ZIP archives, files will be rebuilt to TorrentGZ
|
||||
(TGZ) files. This format is based on the GZip archive format, but with custom header
|
||||
information and a file name replaced by the SHA-1 of the file inside. This is
|
||||
primarily used by external tool Romba (https://github.com/uwedeportivo/romba), but
|
||||
may be used more widely in the future.
|
||||
|
||||
-r, --romba Enable Romba depot directory output
|
||||
As an extension of the parent flag, this outputs the TGZ files into directories
|
||||
based on the structure used by Romba. This uses nested folders using the first
|
||||
4 bytes of the SHA-1, 1 byte for each layer of the directory name. It also
|
||||
includes two auxilary files, .romba_size and .romba_size.backup, that have the
|
||||
compressed size of the folder inside for use with Romba.
|
||||
|
||||
-tzip Enable TorrentZip output
|
||||
Instead of outputting the files to ZIP archives, files will be rebuilt to TorrentZip
|
||||
(TZip) files. This format is based on the ZIP archive format, but with custom header
|
||||
information. This is primarily used by external tool RomVault (http://www.romvault.com/)
|
||||
and is already widely used.
|
||||
|
||||
-do, --directory Enable outputting files uncompressed
|
||||
Instead of outputting the files to ZIP archives, files will be rebuilt to named
|
||||
subdirectories within the output folder. This is useful for when the DAT does not
|
||||
already have the flag specified.
|
||||
|
||||
-h=, --header= Remove headers from hash calculations
|
||||
If this is set, then all files that have copier headers that are detected will
|
||||
have them removed from the hash calculation. This will allow for a headered collection
|
||||
to be hashed without possibly variant information. If a particular header skipper is
|
||||
defined, and that skipper exists, then it will be used instead of trying to find one
|
||||
that matches.
|
||||
|
||||
-7z={0} Set scanning level for 7z archives
|
||||
-gz={2} Set scanning level for GZip archives
|
||||
-rar={2} Set scanning level for RAR archives
|
||||
-zip={0} Set scanning level for ZIP archives
|
||||
For each of the major archive types recognized by the libraries used by this
|
||||
program, scan the archive in one of the following ways:
|
||||
0 Hash both archive and its contents
|
||||
1 Only hash contents of the archive
|
||||
2 Only hash archive itself (treat like a regular file)
|
||||
|
||||
-ud, --update-dat Output updated DAT (rebuild only)
|
||||
Once the files that were able to rebuilt are taken care of, a DAT of the files
|
||||
that could not be matched will be output to the program directory.
|
||||
|
||||
Below are originally from SingleGame (Standalone) -
|
||||
|
||||
-r=rootdir Set the directory name for path size
|
||||
-rd=, --root-dir= Set the directory name for path size
|
||||
-l, --log Enable logging to file
|
||||
-nr, --no-rename Disable single-game mode
|
||||
-df, --disable-force Disable forceunzipping
|
||||
|
||||
Below are originally from TGZConvert / TGZTest (Standalone) -
|
||||
|
||||
-?, -h, -help Show the built-in help text
|
||||
Built-in to most of the programs is a basic help text
|
||||
|
||||
-out= Set the name of the output directory
|
||||
This sets an output folder to be used by when files are rebuilt. It also serves
|
||||
as the base folder if Romba mode is enabled. See -romba for more details
|
||||
|
||||
-t=, -temp= Set the name of the temporary directory
|
||||
Optionally, a temp folder can be supplied in the case the default temp directory
|
||||
(inside the running folder) is not preferred. This is used for any operations that
|
||||
require an archive to be extracted.
|
||||
|
||||
-d, -delete Enable deletion of the input files
|
||||
Optionally, the input files, once processed, can be deleted. This can be useful
|
||||
when the original file structure is no longer needed or if there is limited space
|
||||
on the source drive.
|
||||
|
||||
-r, -romba Enable Romba depot directory output
|
||||
Optionally, this outputs the TGZ files into directories based on the structure
|
||||
used by Romba. This uses nested folders using the first 4 bytes of the SHA-1,
|
||||
1 byte for each layer of the directory name. It also includes two auxilary
|
||||
files, .romba_size and .romba_size.backup, that have the compressed size of the
|
||||
folder inside for use with Romba.
|
||||
|
||||
-7z={0} Set scanning level for 7z archives
|
||||
-gz={2} Set scanning level for GZip archives
|
||||
-rar={2} Set scanning level for RAR archives
|
||||
-zip={0} Set scanning level for ZIP archives
|
||||
For each of the major archive types recognized by the libraries used by this
|
||||
program, scan the archive in one of the following ways:
|
||||
0 Hash both archive and its contents
|
||||
1 Only hash contents of the archive
|
||||
2 Only hash archive itself (treat like a regular file)
|
||||
33
SabreTools.Core/SabreTools.Core.csproj
Normal file
33
SabreTools.Core/SabreTools.Core.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
|
||||
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Licenses\LICENSE">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Licenses\LICENSE.sharpcompress.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="README.1ST">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="README.DEPRECIATED">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
352
SabreTools.Core/Sanitizer.cs
Normal file
352
SabreTools.Core/Sanitizer.cs
Normal file
@@ -0,0 +1,352 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SabreTools.Core
|
||||
{
|
||||
public static class Sanitizer
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a sanitized Date from an input string
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>Date as a string, if possible</returns>
|
||||
public static string CleanDate(string input)
|
||||
{
|
||||
// Null in, null out
|
||||
if (input == null)
|
||||
return null;
|
||||
|
||||
string date = string.Empty;
|
||||
if (input != null)
|
||||
{
|
||||
if (DateTime.TryParse(input, out DateTime dateTime))
|
||||
date = dateTime.ToString();
|
||||
else
|
||||
date = input;
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a game (or rom) name to the WoD standard
|
||||
/// </summary>
|
||||
/// <param name="game">Name of the game to be cleaned</param>
|
||||
/// <returns>The cleaned name</returns>
|
||||
public static string CleanGameName(string game)
|
||||
{
|
||||
///Run the name through the filters to make sure that it's correct
|
||||
game = NormalizeChars(game);
|
||||
game = RussianToLatin(game);
|
||||
game = SearchPattern(game);
|
||||
|
||||
game = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(game).Groups[1].Value;
|
||||
game = game.TrimStart().TrimEnd();
|
||||
return game;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a CRC32 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanCRC32(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.CRCLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a MD5 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanMD5(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.MD5Length);
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
/// <summary>
|
||||
/// Clean a RIPEMD160 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanRIPEMD160(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.RIPEMD160Length);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Clean a SHA1 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanSHA1(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.SHA1Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a SHA256 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanSHA256(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.SHA256Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a SHA384 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanSHA384(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.SHA384Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a SHA512 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanSHA512(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.SHA512Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a hash string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <param name="padding">Amount of characters to pad to</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanHashData(string hash, int padding)
|
||||
{
|
||||
// If we have a known blank hash, return blank
|
||||
if (string.IsNullOrWhiteSpace(hash) || hash == "-" || hash == "_")
|
||||
return string.Empty;
|
||||
|
||||
// Check to see if it's a "hex" hash
|
||||
hash = hash.Trim().Replace("0x", string.Empty);
|
||||
|
||||
// If we have a blank hash now, return blank
|
||||
if (string.IsNullOrWhiteSpace(hash))
|
||||
return string.Empty;
|
||||
|
||||
// If the hash shorter than the required length, pad it
|
||||
if (hash.Length < padding)
|
||||
hash = hash.PadLeft(padding, '0');
|
||||
|
||||
// If the hash is longer than the required length, it's invalid
|
||||
else if (hash.Length > padding)
|
||||
return string.Empty;
|
||||
|
||||
// Now normalize the hash
|
||||
hash = hash.ToLowerInvariant();
|
||||
|
||||
// Otherwise, make sure that every character is a proper match
|
||||
for (int i = 0; i < hash.Length; i++)
|
||||
{
|
||||
if ((hash[i] < '0' || hash[i] > '9') && (hash[i] < 'a' || hash[i] > 'f'))
|
||||
{
|
||||
hash = string.Empty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a hash string from a Listrom DAT
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string CleanListromHashData(string hash)
|
||||
{
|
||||
if (hash.StartsWith("CRC"))
|
||||
return hash.Substring(4, 8).ToLowerInvariant();
|
||||
|
||||
else if (hash.StartsWith("SHA1"))
|
||||
return hash.Substring(5, 40).ToLowerInvariant();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a sanitized size from an input string
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>Size as a long?, if possible</returns>
|
||||
public static long? CleanLong(string input)
|
||||
{
|
||||
long? size = null;
|
||||
if (input != null && input.Contains("0x"))
|
||||
size = Convert.ToInt64(input, 16);
|
||||
|
||||
else if (input != null)
|
||||
{
|
||||
if (Int64.TryParse(input, out long longSize))
|
||||
size = longSize;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all chars that are considered path unsafe
|
||||
/// </summary>
|
||||
/// <param name="s">Input string to clean</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string RemovePathUnsafeCharacters(string s)
|
||||
{
|
||||
List<char> invalidPath = Path.GetInvalidPathChars().ToList();
|
||||
return new string(s.Where(c => !invalidPath.Contains(c)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all unicode-specific chars from a string
|
||||
/// </summary>
|
||||
/// <param name="s">Input string to clean</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string RemoveUnicodeCharacters(string s)
|
||||
{
|
||||
return new string(s.Where(c => c <= 255).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace accented characters
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
private static string NormalizeChars(string input)
|
||||
{
|
||||
string[,] charmap = {
|
||||
{ "Á", "A" }, { "á", "a" },
|
||||
{ "À", "A" }, { "à", "a" },
|
||||
{ "Â", "A" }, { "â", "a" },
|
||||
{ "Ä", "Ae" }, { "ä", "ae" },
|
||||
{ "Ã", "A" }, { "ã", "a" },
|
||||
{ "Å", "A" }, { "å", "a" },
|
||||
{ "Æ", "Ae" }, { "æ", "ae" },
|
||||
{ "Ç", "C" }, { "ç", "c" },
|
||||
{ "Ð", "D" }, { "ð", "d" },
|
||||
{ "É", "E" }, { "é", "e" },
|
||||
{ "È", "E" }, { "è", "e" },
|
||||
{ "Ê", "E" }, { "ê", "e" },
|
||||
{ "Ë", "E" }, { "ë", "e" },
|
||||
{ "ƒ", "f" },
|
||||
{ "Í", "I" }, { "í", "i" },
|
||||
{ "Ì", "I" }, { "ì", "i" },
|
||||
{ "Î", "I" }, { "î", "i" },
|
||||
{ "Ï", "I" }, { "ï", "i" },
|
||||
{ "Ñ", "N" }, { "ñ", "n" },
|
||||
{ "Ó", "O" }, { "ó", "o" },
|
||||
{ "Ò", "O" }, { "ò", "o" },
|
||||
{ "Ô", "O" }, { "ô", "o" },
|
||||
{ "Ö", "Oe" }, { "ö", "oe" },
|
||||
{ "Õ", "O" }, { "õ", "o" },
|
||||
{ "Ø", "O" }, { "ø", "o" },
|
||||
{ "Š", "S" }, { "š", "s" },
|
||||
{ "ß", "ss" },
|
||||
{ "Þ", "B" }, { "þ", "b" },
|
||||
{ "Ú", "U" }, { "ú", "u" },
|
||||
{ "Ù", "U" }, { "ù", "u" },
|
||||
{ "Û", "U" }, { "û", "u" },
|
||||
{ "Ü", "Ue" }, { "ü", "ue" },
|
||||
{ "ÿ", "y" },
|
||||
{ "Ý", "Y" }, { "ý", "y" },
|
||||
{ "Ž", "Z" }, { "ž", "z" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < charmap.GetLength(0); i++)
|
||||
{
|
||||
input = input.Replace(charmap[i, 0], charmap[i, 1]);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert Cyrillic lettering to Latin lettering
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
private static string RussianToLatin(string input)
|
||||
{
|
||||
string[,] charmap = {
|
||||
{ "А", "A" }, { "Б", "B" }, { "В", "V" }, { "Г", "G" }, { "Д", "D" },
|
||||
{ "Е", "E" }, { "Ё", "Yo" }, { "Ж", "Zh" }, { "З", "Z" }, { "И", "I" },
|
||||
{ "Й", "J" }, { "К", "K" }, { "Л", "L" }, { "М", "M" }, { "Н", "N" },
|
||||
{ "О", "O" }, { "П", "P" }, { "Р", "R" }, { "С", "S" }, { "Т", "T" },
|
||||
{ "У", "U" }, { "Ф", "f" }, { "Х", "Kh" }, { "Ц", "Ts" }, { "Ч", "Ch" },
|
||||
{ "Ш", "Sh" }, { "Щ", "Sch" }, { "Ъ", string.Empty }, { "Ы", "y" }, { "Ь", string.Empty },
|
||||
{ "Э", "e" }, { "Ю", "yu" }, { "Я", "ya" }, { "а", "a" }, { "б", "b" },
|
||||
{ "в", "v" }, { "г", "g" }, { "д", "d" }, { "е", "e" }, { "ё", "yo" },
|
||||
{ "ж", "zh" }, { "з", "z" }, { "и", "i" }, { "й", "j" }, { "к", "k" },
|
||||
{ "л", "l" }, { "м", "m" }, { "н", "n" }, { "о", "o" }, { "п", "p" },
|
||||
{ "р", "r" }, { "с", "s" }, { "т", "t" }, { "у", "u" }, { "ф", "f" },
|
||||
{ "х", "kh" }, { "ц", "ts" }, { "ч", "ch" }, { "ш", "sh" }, { "щ", "sch" },
|
||||
{ "ъ", string.Empty }, { "ы", "y" }, { "ь", string.Empty }, { "э", "e" }, { "ю", "yu" },
|
||||
{ "я", "ya" },
|
||||
};
|
||||
|
||||
for (int i = 0; i < charmap.GetLength(0); i++)
|
||||
{
|
||||
input = input.Replace(charmap[i, 0], charmap[i, 1]);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace special characters and patterns
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
private static string SearchPattern(string input)
|
||||
{
|
||||
string[,] charmap = {
|
||||
{ @"~", " - " },
|
||||
{ @"_", " " },
|
||||
{ @":", " " },
|
||||
{ @">", ")" },
|
||||
{ @"<", "(" },
|
||||
{ @"\|", "-" },
|
||||
{ "\"", "'" },
|
||||
{ @"\*", "." },
|
||||
{ @"\\", "-" },
|
||||
{ @"/", "-" },
|
||||
{ @"\?", " " },
|
||||
{ @"\(([^)(]*)\(([^)]*)\)([^)(]*)\)", " " },
|
||||
{ @"\(([^)]+)\)", " " },
|
||||
{ @"\[([^]]+)\]", " " },
|
||||
{ @"\{([^}]+)\}", " " },
|
||||
{ @"(ZZZJUNK|ZZZ-UNK-|ZZZ-UNK |zzz unknow |zzz unk |Copy of |[.][a-z]{3}[.][a-z]{3}[.]|[.][a-z]{3}[.])", " " },
|
||||
{ @" (r|rev|v|ver)\s*[\d\.]+[^\s]*", " " },
|
||||
{ @"(( )|(\A))(\d{6}|\d{8})(( )|(\Z))", " " },
|
||||
{ @"(( )|(\A))(\d{1,2})-(\d{1,2})-(\d{4}|\d{2})", " " },
|
||||
{ @"(( )|(\A))(\d{4}|\d{2})-(\d{1,2})-(\d{1,2})", " " },
|
||||
{ @"[-]+", "-" },
|
||||
{ @"\A\s*\)", " " },
|
||||
{ @"\A\s*(,|-)", " " },
|
||||
{ @"\s+", " " },
|
||||
{ @"\s+,", "," },
|
||||
{ @"\s*(,|-)\s*\Z", " " },
|
||||
};
|
||||
|
||||
for (int i = 0; i < charmap.GetLength(0); i++)
|
||||
{
|
||||
input = Regex.Replace(input, charmap[i, 0], charmap[i, 1]);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
||||
106
SabreTools.Core/Utilities.cs
Normal file
106
SabreTools.Core/Utilities.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Static utility functions used throughout the library
|
||||
/// </summary>
|
||||
public static class Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert a byte array to a hex string
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array to convert</param>
|
||||
/// <returns>Hex string representing the byte array</returns>
|
||||
/// <link>http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa</link>
|
||||
public static string ByteArrayToString(byte[] bytes)
|
||||
{
|
||||
// If we get null in, we send null out
|
||||
if (bytes == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
string hex = BitConverter.ToString(bytes);
|
||||
return hex.Replace("-", string.Empty).ToLowerInvariant();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a hex string to a byte array
|
||||
/// </summary>
|
||||
/// <param name="hex">Hex string to convert</param>
|
||||
/// <returns>Byte array represenging the hex string</returns>
|
||||
/// <link>http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa</link>
|
||||
public static byte[] StringToByteArray(string hex)
|
||||
{
|
||||
// If we get null in, we send null out
|
||||
if (hex == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
int NumberChars = hex.Length;
|
||||
byte[] bytes = new byte[NumberChars / 2];
|
||||
for (int i = 0; i < NumberChars; i += 2)
|
||||
{
|
||||
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert .NET DateTime to MS-DOS date format
|
||||
/// </summary>
|
||||
/// <param name="dateTime">.NET DateTime object to convert</param>
|
||||
/// <returns>UInt32 representing the MS-DOS date</returns>
|
||||
/// <remarks>
|
||||
/// Adapted from 7-zip Source Code: CPP/Windows/TimeUtils.cpp:FileTimeToDosTime
|
||||
/// </remarks>
|
||||
public static uint ConvertDateTimeToMsDosTimeFormat(DateTime dateTime)
|
||||
{
|
||||
uint year = (uint)((dateTime.Year - 1980) % 128);
|
||||
uint mon = (uint)dateTime.Month;
|
||||
uint day = (uint)dateTime.Day;
|
||||
uint hour = (uint)dateTime.Hour;
|
||||
uint min = (uint)dateTime.Minute;
|
||||
uint sec = (uint)dateTime.Second;
|
||||
|
||||
return (year << 25) | (mon << 21) | (day << 16) | (hour << 11) | (min << 5) | (sec >> 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert MS-DOS date format to .NET DateTime
|
||||
/// </summary>
|
||||
/// <param name="msDosDateTime">UInt32 representing the MS-DOS date to convert</param>
|
||||
/// <returns>.NET DateTime object representing the converted date</returns>
|
||||
/// <remarks>
|
||||
/// Adapted from 7-zip Source Code: CPP/Windows/TimeUtils.cpp:DosTimeToFileTime
|
||||
/// </remarks>
|
||||
public static DateTime ConvertMsDosTimeFormatToDateTime(uint msDosDateTime)
|
||||
{
|
||||
return new DateTime((int)(1980 + (msDosDateTime >> 25)), (int)((msDosDateTime >> 21) & 0xF), (int)((msDosDateTime >> 16) & 0x1F),
|
||||
(int)((msDosDateTime >> 11) & 0x1F), (int)((msDosDateTime >> 5) & 0x3F), (int)((msDosDateTime & 0x1F) * 2));
|
||||
}
|
||||
|
||||
/// Indicates whether the specified array is null or has a length of zero
|
||||
/// </summary>
|
||||
/// <param name="array">The array to test</param>
|
||||
/// <returns>true if the array parameter is null or has a length of zero; otherwise, false.</returns>
|
||||
/// <link>https://stackoverflow.com/questions/8560106/isnullorempty-equivalent-for-array-c-sharp</link>
|
||||
public static bool IsNullOrEmpty(this Array array)
|
||||
{
|
||||
return (array == null || array.Length == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user