mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools.Library] Update folder name
This commit is contained in:
59
SabreTools.Library/Data/Build.cs
Normal file
59
SabreTools.Library/Data/Build.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Helper.Data
|
||||
{
|
||||
public static class Build
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if running in a Mono environment
|
||||
/// </summary>
|
||||
public static bool MonoEnvironment
|
||||
{
|
||||
get { return (Type.GetType("Mono.Runtime") != null); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Readies the console and outputs the header
|
||||
/// </summary>
|
||||
/// <param name="name">The name to be displayed as the program</param>B
|
||||
public static void Start(string name)
|
||||
{
|
||||
// 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 = name + " " + 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 (!MonoEnvironment)
|
||||
{
|
||||
Console.SetBufferSize(Console.BufferWidth, 999);
|
||||
formertext = Console.ForegroundColor;
|
||||
formerback = Console.BackgroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.BackgroundColor = ConsoleColor.Blue;
|
||||
}
|
||||
|
||||
Console.Title = name + " " + 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 (!MonoEnvironment)
|
||||
{
|
||||
Console.ForegroundColor = formertext;
|
||||
Console.BackgroundColor = formerback;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
154
SabreTools.Library/Data/Constants.cs
Normal file
154
SabreTools.Library/Data/Constants.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using SabreTools.Helper.Tools;
|
||||
|
||||
namespace SabreTools.Helper.Data
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// The current toolset version to be used by all child applications
|
||||
/// </summary>
|
||||
public static string Version = "v0.9.5-" + Assembly.GetExecutingAssembly().GetLinkerTime().ToString("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 const string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
|
||||
public const string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
||||
public const string SHA256Zero = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";
|
||||
public const string SHA384Zero = "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7";
|
||||
public const string SHA512Zero = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Byte (1000-based) size comparisons
|
||||
|
||||
public const long KiloByte = 1000;
|
||||
public static long MegaByte = (long)Math.Pow(KiloByte, 2);
|
||||
public static long GigaByte = (long)Math.Pow(KiloByte, 3);
|
||||
public static long TeraByte = (long)Math.Pow(KiloByte, 4);
|
||||
public static long PetaByte = (long)Math.Pow(KiloByte, 5);
|
||||
public static long ExaByte = (long)Math.Pow(KiloByte, 6);
|
||||
public static long ZettaByte = (long)Math.Pow(KiloByte, 7);
|
||||
public static long YottaByte = (long)Math.Pow(KiloByte, 8);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Byte (1024-based) size comparisons
|
||||
|
||||
public const long KibiByte = 1024;
|
||||
public static long MibiByte = (long)Math.Pow(KibiByte, 2);
|
||||
public static long GibiByte = (long)Math.Pow(KibiByte, 3);
|
||||
public static long TibiByte = (long)Math.Pow(KibiByte, 4);
|
||||
public static long PibiByte = (long)Math.Pow(KibiByte, 5);
|
||||
public static long ExiByte = (long)Math.Pow(KibiByte, 6);
|
||||
public static long ZittiByte = (long)Math.Pow(KibiByte, 7);
|
||||
public static long YittiByte = (long)Math.Pow(KibiByte, 8);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Database schema
|
||||
|
||||
public const string HeadererDbSchema = "Headerer";
|
||||
public const string HeadererFileName = "Headerer.sqlite";
|
||||
public const string HeadererConnectionString = "Data Source=" + HeadererFileName + ";Version = 3;";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hash string length constants
|
||||
|
||||
public const int CRCLength = 8;
|
||||
public const int MD5Length = 32;
|
||||
public const int SHA1Length = 40;
|
||||
public const int SHA256Length = 64;
|
||||
public const int SHA384Length = 96;
|
||||
public const int SHA512Length = 128;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Magic numbers as strings
|
||||
|
||||
public const string SevenZipSig = "377ABCAF271C";
|
||||
public const string GzSig = "1F8B";
|
||||
public const string RarSig = "526172211A0700";
|
||||
public const string RarFiveSig = "526172211A070100";
|
||||
public const string TarSig = "7573746172202000";
|
||||
public const string TarZeroSig = "7573746172003030";
|
||||
public const string ZipSig = "504B0304";
|
||||
public const string ZipSigEmpty = "504B0506";
|
||||
public const string ZipSigSpanned = "504B0708";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Regular Expressions
|
||||
|
||||
public const string XmlPattern = @"<(.*?)>(.*?)</(.*?)>";
|
||||
public const string HeaderPatternCMP = @"(^.*?) \($";
|
||||
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)
|
||||
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 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)
|
||||
06-07 ArchiveVersion (0x00, 0x03)
|
||||
The rest is unknown
|
||||
*/
|
||||
public static byte[] Torrent7ZipHeader = new byte[] { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c, 0x00, 0x03 };
|
||||
public 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 Identification 1 (0x1F)
|
||||
01 Identification 2 (0x8B)
|
||||
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 static byte[] TorrentGZHeader = new byte[] { 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00 };
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
369
SabreTools.Library/Data/Enums.cs
Normal file
369
SabreTools.Library/Data/Enums.cs
Normal file
@@ -0,0 +1,369 @@
|
||||
namespace SabreTools.Helper.Data
|
||||
{
|
||||
#region Archival
|
||||
|
||||
/// <summary>
|
||||
/// Version of tool archive made by
|
||||
/// </summary>
|
||||
public enum ArchiveVersion : ushort
|
||||
{
|
||||
MSDOSandOS2 = 0,
|
||||
Amiga = 1,
|
||||
OpenVMS = 2,
|
||||
UNIX = 3,
|
||||
VMCMS = 4,
|
||||
AtariST = 5,
|
||||
OS2HPFS = 6,
|
||||
Macintosh = 7,
|
||||
ZSystem = 8,
|
||||
CPM = 9,
|
||||
WindowsNTFS = 10,
|
||||
MVS = 11,
|
||||
VSE = 12,
|
||||
AcornRisc = 13,
|
||||
VFAT = 14,
|
||||
AlternateMVS = 15,
|
||||
BeOS = 16,
|
||||
Tandem = 17,
|
||||
OS400 = 18,
|
||||
OSXDarwin = 19,
|
||||
TorrentZip = 20,
|
||||
TorrentZip64 = 45,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compression method based on flag
|
||||
/// </summary>
|
||||
public enum CompressionMethod : ushort
|
||||
{
|
||||
Stored = 0,
|
||||
Shrunk = 1,
|
||||
ReducedCompressionFactor1 = 2,
|
||||
ReducedCompressionFactor2 = 3,
|
||||
ReducedCompressionFactor3 = 4,
|
||||
ReducedCompressionFactor4 = 5,
|
||||
Imploded = 6,
|
||||
Tokenizing = 7,
|
||||
Deflated = 8,
|
||||
Delfate64 = 9,
|
||||
PKWAREDataCompressionLibrary = 10,
|
||||
BZIP2 = 12,
|
||||
LZMA = 14,
|
||||
IBMTERSE = 18,
|
||||
IBMLZ77 = 19,
|
||||
WavPak = 97,
|
||||
PPMdVersionIRev1 = 98,
|
||||
|
||||
// Reserved and unused (SHOULD NOT BE USED)
|
||||
Type11 = 11,
|
||||
Type13 = 13,
|
||||
Type15 = 15,
|
||||
Type16 = 16,
|
||||
Type17 = 17,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output format for rebuilt files
|
||||
/// </summary>
|
||||
public enum OutputFormat
|
||||
{
|
||||
// Currently implemented
|
||||
Folder = 0,
|
||||
TorrentZip = 1,
|
||||
TorrentGzip = 2,
|
||||
TapeArchive = 5,
|
||||
|
||||
// Currently unimplemented
|
||||
Torrent7Zip = 3,
|
||||
TorrentRar = 4,
|
||||
TorrentXZ = 6,
|
||||
TorrentLrzip = 7,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR extra area flag
|
||||
/// </summary>
|
||||
public enum RarExtraAreaFlag : uint
|
||||
{
|
||||
FileEncryption = 0x01,
|
||||
FileHash = 0x02,
|
||||
FileTime = 0x03,
|
||||
FileVersion = 0x04,
|
||||
Redirection = 0x05,
|
||||
UnixOwner = 0x06,
|
||||
ServiceData = 0x07,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR header types
|
||||
/// </summary>
|
||||
public enum RarHeaderType : uint
|
||||
{
|
||||
MainArchiveHeader = 1,
|
||||
File = 2,
|
||||
Service = 3,
|
||||
ArchiveEncryption = 4,
|
||||
EndOfArchive = 5,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR entry redirection type
|
||||
/// </summary>
|
||||
public enum RarRedirectionType : uint
|
||||
{
|
||||
UnixSymlink = 0x0001,
|
||||
WindowsSymlink = 0x0002,
|
||||
WindowsJunction = 0x0003,
|
||||
HardLink = 0x0004,
|
||||
FileCopy = 0x0005,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 7zip Properties
|
||||
/// </summary>
|
||||
public enum SevenZipProperties : uint
|
||||
{
|
||||
kEnd = 0x00,
|
||||
|
||||
kHeader = 0x01,
|
||||
|
||||
kArchiveProperties = 0x02,
|
||||
|
||||
kAdditionalStreamsInfo = 0x03,
|
||||
kMainStreamsInfo = 0x04,
|
||||
kFilesInfo = 0x05,
|
||||
|
||||
kPackInfo = 0x06,
|
||||
kUnPackInfo = 0x07,
|
||||
kSubStreamsInfo = 0x08,
|
||||
|
||||
kSize = 0x09,
|
||||
kCRC = 0x0A,
|
||||
|
||||
kFolder = 0x0B,
|
||||
|
||||
kCodersUnPackSize = 0x0C,
|
||||
kNumUnPackStream = 0x0D,
|
||||
|
||||
kEmptyStream = 0x0E,
|
||||
kEmptyFile = 0x0F,
|
||||
kAnti = 0x10,
|
||||
|
||||
kName = 0x11,
|
||||
kCTime = 0x12,
|
||||
kATime = 0x13,
|
||||
kMTime = 0x14,
|
||||
kWinAttributes = 0x15,
|
||||
kComment = 0x16,
|
||||
|
||||
kEncodedHeader = 0x17,
|
||||
|
||||
kStartPos = 0x18,
|
||||
kDummy = 0x19,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zip open type
|
||||
/// </summary>
|
||||
/// <remarks>https://raw.githubusercontent.com/gjefferyes/RomVault/5a93500001f0d068f32cf77a048950717507f733/ROMVault2/SupportedFiles/ZipEnums.cs</remarks>
|
||||
public enum ZipOpenType
|
||||
{
|
||||
Closed,
|
||||
OpenRead,
|
||||
OpenWrite
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zip testing type
|
||||
/// </summary>
|
||||
/// <remarks>https://raw.githubusercontent.com/gjefferyes/RomVault/5a93500001f0d068f32cf77a048950717507f733/ROMVault2/SupportedFiles/ZipEnums.cs</remarks>
|
||||
public enum ZipReturn
|
||||
{
|
||||
ZipGood,
|
||||
ZipFileLocked,
|
||||
ZipFileCountError,
|
||||
ZipSignatureError,
|
||||
ZipExtraDataOnEndOfZip,
|
||||
ZipUnsupportedCompression,
|
||||
ZipLocalFileHeaderError,
|
||||
ZipCentralDirError,
|
||||
ZipEndOfCentralDirectoryError,
|
||||
Zip64EndOfCentralDirError,
|
||||
Zip64EndOfCentralDirectoryLocatorError,
|
||||
ZipReadingFromOutputFile,
|
||||
ZipWritingToInputFile,
|
||||
ZipErrorGettingDataStream,
|
||||
ZipCRCDecodeError,
|
||||
ZipDecodeError,
|
||||
ZipFileNameToLong,
|
||||
ZipFileAlreadyOpen,
|
||||
ZipCannotFastOpen,
|
||||
ZipErrorOpeningFile,
|
||||
ZipErrorFileNotFound,
|
||||
ZipErrorReadingFile,
|
||||
ZipErrorTimeStamp,
|
||||
ZipErrorRollBackFile,
|
||||
ZipUntested
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatFile related
|
||||
|
||||
/// <summary>
|
||||
/// Determines forcemerging tag for DAT output
|
||||
/// </summary>
|
||||
public enum ForceMerging
|
||||
{
|
||||
None = 0,
|
||||
Split,
|
||||
Merged,
|
||||
NonMerged,
|
||||
Full,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines forcenodump tag for DAT output
|
||||
/// </summary>
|
||||
public enum ForceNodump
|
||||
{
|
||||
None = 0,
|
||||
Obsolete,
|
||||
Required,
|
||||
Ignore,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines forcepacking tag for DAT output
|
||||
/// </summary>
|
||||
public enum ForcePacking
|
||||
{
|
||||
None = 0,
|
||||
Zip,
|
||||
Unzip,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines which files should be skipped in DFD
|
||||
/// </summary>
|
||||
public enum SkipFileType
|
||||
{
|
||||
None = 0,
|
||||
Archive,
|
||||
File,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines how the current dictionary is sorted by
|
||||
/// </summary>
|
||||
public enum SortedBy
|
||||
{
|
||||
Default = 0,
|
||||
Size,
|
||||
CRC,
|
||||
MD5,
|
||||
SHA1,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
Game,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines how a DAT will be split internally
|
||||
/// </summary>
|
||||
public enum SplitType
|
||||
{
|
||||
None = 0,
|
||||
NonMerged,
|
||||
Merged,
|
||||
FullNonMerged,
|
||||
Split,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatItem related
|
||||
|
||||
/// <summary>
|
||||
/// Determine what type of file an item is
|
||||
/// </summary>
|
||||
public enum ItemType
|
||||
{
|
||||
Rom = 0,
|
||||
Disk = 1,
|
||||
Sample = 2,
|
||||
Release = 3,
|
||||
BiosSet = 4,
|
||||
Archive = 5,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Help related
|
||||
|
||||
/// <summary>
|
||||
/// Determines the feature type to check for
|
||||
/// </summary>
|
||||
public enum FeatureType
|
||||
{
|
||||
Flag = 0,
|
||||
String,
|
||||
List,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logging related
|
||||
|
||||
/// <summary>
|
||||
/// Severity of the logging statement
|
||||
/// </summary>
|
||||
public enum LogLevel
|
||||
{
|
||||
VERBOSE = 0,
|
||||
USER,
|
||||
WARNING,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skippers and Mappers
|
||||
|
||||
/// <summary>
|
||||
/// Determines the header skip operation
|
||||
/// </summary>
|
||||
public enum HeaderSkipOperation
|
||||
{
|
||||
None = 0,
|
||||
Bitswap,
|
||||
Byteswap,
|
||||
Wordswap,
|
||||
WordByteswap,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the type of test to be done
|
||||
/// </summary>
|
||||
public enum HeaderSkipTest
|
||||
{
|
||||
Data = 0,
|
||||
Or,
|
||||
Xor,
|
||||
And,
|
||||
File,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the operator to be used in a file test
|
||||
/// </summary>
|
||||
public enum HeaderSkipTestFileOperator
|
||||
{
|
||||
Equal = 0,
|
||||
Less,
|
||||
Greater,
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
320
SabreTools.Library/Data/Flags.cs
Normal file
320
SabreTools.Library/Data/Flags.cs
Normal file
@@ -0,0 +1,320 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Helper.Data
|
||||
{
|
||||
#region Archival
|
||||
|
||||
/// <summary>
|
||||
/// Determines the level to scan archives at
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ArchiveScanLevel
|
||||
{
|
||||
// 7zip
|
||||
SevenZipExternal = 0x00001,
|
||||
SevenZipInternal = 0x00002,
|
||||
SevenZipBoth = SevenZipExternal | SevenZipInternal,
|
||||
|
||||
// GZip
|
||||
GZipExternal = 0x00010,
|
||||
GZipInternal = 0x00020,
|
||||
GZipBoth = GZipExternal | GZipInternal,
|
||||
|
||||
// RAR
|
||||
RarExternal = 0x00100,
|
||||
RarInternal = 0x00200,
|
||||
RarBoth = RarExternal | RarInternal,
|
||||
|
||||
// Zip
|
||||
ZipExternal = 0x01000,
|
||||
ZipInternal = 0x02000,
|
||||
ZipBoth = ZipExternal | ZipInternal,
|
||||
|
||||
// Tar
|
||||
TarExternal = 0x10000,
|
||||
TarInternal = 0x20000,
|
||||
TarBoth = TarExternal | TarInternal,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the archive general bit flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum GeneralPurposeBitFlag : ushort
|
||||
{
|
||||
Encrypted = 0x0001,
|
||||
ZeroedCRCAndSize = 0x0008,
|
||||
CompressedPatchedData = 0x0020,
|
||||
StrongEncryption = 0x0040,
|
||||
LanguageEncodingFlag = 0x0800,
|
||||
EncryptedCentralDirectory = 0x2000,
|
||||
|
||||
// For Method 6 - Imploding
|
||||
Imploding8KSlidingDictionary = 0x0002,
|
||||
Imploding3ShannonFanoTrees = 0x0004,
|
||||
|
||||
// For Methods 8 and 9 - Deflating
|
||||
DeflatingMaximumCompression = 0x0002,
|
||||
DeflatingFastCompression = 0x0004,
|
||||
DeflatingSuperFastCompression = 0x0006,
|
||||
EnhancedDeflating = 0x0010,
|
||||
|
||||
// For Method 14 - LZMA
|
||||
LZMAEOSMarkerUsed = 0x0002,
|
||||
|
||||
// Reserved and unused (SHOULD NOT BE USED)
|
||||
Bit7 = 0x0080,
|
||||
Bit8 = 0x0100,
|
||||
Bit9 = 0x0200,
|
||||
Bit10 = 0x0400,
|
||||
Bit12 = 0x1000, // Reserved by PKWARE for enhanced compression
|
||||
Bit14 = 0x4000, // Reserved by PKWARE
|
||||
Bit15 = 0x8000, // Reserved by PKWARE
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal file attributes used by archives
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum InternalFileAttributes : ushort
|
||||
{
|
||||
ASCIIOrTextFile = 0x0001,
|
||||
RecordLengthControl = 0x0002,
|
||||
|
||||
// Reserved and unused (SHOULD NOT BE USED)
|
||||
Bit1 = 0x0002,
|
||||
Bit2 = 0x0004,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR archive flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum RarArchiveFlags : uint
|
||||
{
|
||||
Volume = 0x0001, // Volume. Archive is a part of multivolume set.
|
||||
VolumeNumberField = 0x0002, // Volume number field is present. This flag is present in all volumes except first.
|
||||
Solid = 0x0004, // Solid archive.
|
||||
RecoveryRecordPresent = 0x0008, // Recovery record is present.
|
||||
Locked = 0x0010, // Locked archive.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR entry encryption flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum RarEncryptionFlags : uint
|
||||
{
|
||||
PasswordCheckDataPresent = 0x0001,
|
||||
UseTweakedChecksums = 0x0002,
|
||||
|
||||
/*
|
||||
If flag 0x0002 is present, RAR transforms the checksum preserving file or service data integrity, so it becomes dependent on
|
||||
encryption key. It makes guessing file contents based on checksum impossible. It affects both data CRC32 in file header and
|
||||
checksums in file hash record in extra area.
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR file flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum RarFileFlags : uint
|
||||
{
|
||||
Directory = 0x0001, // Directory file system object (file header only)
|
||||
TimeInUnix = 0x0002, // Time field in Unix format is present
|
||||
CRCPresent = 0x0004, // CRC32 field is present
|
||||
UnpackedSizeUnknown = 0x0008, // Unpacked size is unknown
|
||||
|
||||
/*
|
||||
If flag 0x0008 is set, unpacked size field is still present, but must be ignored and extraction
|
||||
must be performed until reaching the end of compression stream. This flag can be set if actual
|
||||
file size is larger than reported by OS or if file size is unknown such as for all volumes except
|
||||
last when archiving from stdin to multivolume archive
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR header flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum RarHeaderFlags : uint
|
||||
{
|
||||
ExtraAreaPresent = 0x0001, // Extra area is present in the end of header
|
||||
DataAreaPresent = 0x0002, // Data area is present in the end of header
|
||||
BlocksWithUnknownType = 0x0004, // Blocks with unknown type and this flag must be skipped when updating an archive
|
||||
DataAreaContinuingFromPrevious = 0x0008, // Data area is continuing from previous volume
|
||||
DataAreaContinuingToNext = 0x0010, // Data area is continuing in next volume
|
||||
BlockDependsOnPreceding = 0x0020, // Block depends on preceding file block
|
||||
PreserveChildBlock = 0x0040, // Preserve a child block if host block is modified
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum RarUnixOwnerRecordFlags : uint
|
||||
{
|
||||
UserNameStringIsPresent = 0x0001,
|
||||
GroupNameStringIsPresent = 0x0002,
|
||||
NumericUserIdIsPresent = 0x0004,
|
||||
NumericGroupIdIsPresent = 0x0008,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RAR entry time flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum RarTimeFlags : uint
|
||||
{
|
||||
TimeInUnixFormat = 0x0001,
|
||||
ModificationTimePresent = 0x0002,
|
||||
CreationTimePresent = 0x0004,
|
||||
LastAccessTimePresent = 0x0008,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zipfile special status
|
||||
/// </summary>
|
||||
/// <remarks>https://github.com/gjefferyes/RomVault/blob/5a93500001f0d068f32cf77a048950717507f733/ROMVault2/SupportedFiles/ZipEnums.cs</remarks>
|
||||
[Flags]
|
||||
public enum ZipStatus
|
||||
{
|
||||
None = 0x0,
|
||||
TorrentZip = 0x1,
|
||||
ExtraData = 0x2
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatFile related
|
||||
|
||||
/// <summary>
|
||||
/// Determines the DAT output format
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DatFormat
|
||||
{
|
||||
// XML Formats
|
||||
Logiqx = 0x01,
|
||||
SoftwareList = Logiqx << 1,
|
||||
OfflineList = SoftwareList << 1,
|
||||
SabreDat = OfflineList << 1,
|
||||
|
||||
// Propietary Formats
|
||||
ClrMamePro = SabreDat << 1,
|
||||
RomCenter = ClrMamePro << 1,
|
||||
DOSCenter = RomCenter << 1,
|
||||
AttractMode = DOSCenter << 1,
|
||||
|
||||
// Standardized Text Formats
|
||||
MissFile = AttractMode << 1,
|
||||
CSV = MissFile << 1,
|
||||
TSV = CSV << 1,
|
||||
|
||||
// SFV-similar Formats
|
||||
RedumpSFV = TSV << 1,
|
||||
RedumpMD5 = RedumpSFV << 1,
|
||||
RedumpSHA1 = RedumpMD5 << 1,
|
||||
RedumpSHA256 = RedumpSHA1 << 1,
|
||||
RedumpSHA384 = RedumpSHA256 << 1,
|
||||
RedumpSHA512 = RedumpSHA384 << 1,
|
||||
|
||||
// Specialty combinations
|
||||
ALL = 0xFFFFF,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines which diffs should be created
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DiffMode
|
||||
{
|
||||
// Standard diffs
|
||||
Dupes = 0x01,
|
||||
NoDupes = Dupes << 1,
|
||||
Individuals = NoDupes << 1,
|
||||
All = Dupes | NoDupes | Individuals,
|
||||
|
||||
// Cascaded diffs
|
||||
Cascade = Individuals << 1,
|
||||
ReverseCascade = Cascade << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine which format to output Stats to
|
||||
/// </summary>
|
||||
/// [Flags]
|
||||
public enum StatDatFormat
|
||||
{
|
||||
None = 0x01,
|
||||
HTML = None << 1,
|
||||
CSV = HTML << 1,
|
||||
TSV = CSV << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine what hashes to strip from the DAT
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Hash
|
||||
{
|
||||
CRC = 0x0001,
|
||||
MD5 = CRC << 1,
|
||||
SHA1 = MD5 << 1,
|
||||
SHA256 = SHA1 << 1,
|
||||
SHA384 = SHA256 << 1,
|
||||
SHA512 = SHA384 << 1,
|
||||
xxHash = SHA512 << 1,
|
||||
|
||||
// Special combinations
|
||||
Standard = CRC | MD5 | SHA1,
|
||||
DeepHashes = SHA256 | SHA384 | SHA512 | xxHash,
|
||||
SecureHashes = MD5 | SHA1 | SHA256 | SHA384 | SHA512 | xxHash,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatItem related
|
||||
|
||||
/// <summary>
|
||||
/// Determines which type of duplicate a file is
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DupeType
|
||||
{
|
||||
// Type of match
|
||||
Hash = 0x01,
|
||||
All = 0x02,
|
||||
|
||||
// Location of match
|
||||
Internal = 0x10,
|
||||
External = 0x20,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the status of the item
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ItemStatus
|
||||
{
|
||||
NULL = 0x00, // This is a fake flag that is used for filter only
|
||||
None = 0x01,
|
||||
Good = 0x02,
|
||||
BadDump = 0x04,
|
||||
Nodump = 0x08,
|
||||
Verified = 0x10,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine what type of machine it is
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum MachineType
|
||||
{
|
||||
NULL = 0x00, // This is a fake flag used for filter only
|
||||
None = 0x01,
|
||||
Bios = 0x02,
|
||||
Device = 0x04,
|
||||
Mechanical = 0x08,
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
77
SabreTools.Library/Data/Globals.cs
Normal file
77
SabreTools.Library/Data/Globals.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if MONO
|
||||
using System.IO;
|
||||
#else
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
#endif
|
||||
|
||||
namespace SabreTools.Helper.Data
|
||||
{
|
||||
public class Globals
|
||||
{
|
||||
#region Private implementations
|
||||
|
||||
private static Logger _logger = null;
|
||||
private static int _maxDegreeOfParallelism = 4;
|
||||
private static string _exeName = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
|
||||
private static string _exeDir = Path.GetDirectoryName(_exeName);
|
||||
private static string _args = string.Join(" ", Environment.GetCommandLineArgs());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public accessors
|
||||
|
||||
public static Logger Logger
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_logger == null)
|
||||
{
|
||||
_logger = new Logger();
|
||||
}
|
||||
return _logger;
|
||||
}
|
||||
set { _logger = value; }
|
||||
}
|
||||
public static int MaxDegreeOfParallelism
|
||||
{
|
||||
set { _maxDegreeOfParallelism = value; }
|
||||
}
|
||||
public static ParallelOptions ParallelOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ParallelOptions()
|
||||
{
|
||||
MaxDegreeOfParallelism = _maxDegreeOfParallelism
|
||||
};
|
||||
}
|
||||
}
|
||||
public static string ExeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _exeName;
|
||||
}
|
||||
}
|
||||
public static string ExeDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return _exeDir;
|
||||
}
|
||||
}
|
||||
public static string CommandLineArgs
|
||||
{
|
||||
get
|
||||
{
|
||||
return _args;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user