mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Constants] Make file headers constants
This commit is contained in:
@@ -10,18 +10,25 @@ namespace SabreTools.Helper
|
||||
public static string Version = "v0.9.0";
|
||||
public static int HeaderHeight = 3;
|
||||
|
||||
// 0-byte file constants
|
||||
#region 0-byte file constants
|
||||
|
||||
public static long SizeZero = 0;
|
||||
public static string CRCZero = "00000000";
|
||||
public static string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
|
||||
public static string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
|
||||
|
||||
// Hash string length constants
|
||||
#endregion
|
||||
|
||||
#region Hash string length constants
|
||||
|
||||
public static int CRCLength = 8;
|
||||
public static int MD5Length = 32;
|
||||
public static int SHA1Length = 40;
|
||||
|
||||
// Regex File Name Patterns
|
||||
#endregion
|
||||
|
||||
#region Regex File Name Patterns
|
||||
|
||||
public static string DefaultPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.dat$";
|
||||
public static string DefaultSpecialPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.xml$";
|
||||
public static string GoodPattern = @"^(Good.*?)_.*\.dat";
|
||||
@@ -41,36 +48,68 @@ namespace SabreTools.Helper
|
||||
public static string TruripPattern = @"^(.*) - .* \(trurip_XML\)\.dat$";
|
||||
public static string ZandroPattern = @"^SMW-.*.xml";
|
||||
|
||||
// Regex Mapped Name Patterns
|
||||
#endregion
|
||||
|
||||
#region Regex Mapped Name Patterns
|
||||
|
||||
public static string RemappedPattern = @"^(.*) - (.*)$";
|
||||
|
||||
// Regex Date Patterns
|
||||
#endregion
|
||||
|
||||
#region Regex Date Patterns
|
||||
|
||||
public static string DefaultDatePattern = @"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})";
|
||||
public static string NoIntroDatePattern = @"(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})";
|
||||
public static string NoIntroSpecialDatePattern = @"(\d{4})(\d{2})(\d{2})";
|
||||
public static string RedumpDatePattern = @"(\d{4})(\d{2})(\d{2}) (\d{2})-(\d{2})-(\d{2})";
|
||||
public static string TosecDatePattern = @"(\d{4})-(\d{2})-(\d{2})";
|
||||
|
||||
// Regex conversion patterns
|
||||
#endregion
|
||||
|
||||
#region Regex conversion patterns
|
||||
|
||||
public static string HeaderPatternCMP = @"(^.*?) \($";
|
||||
public static string ItemPatternCMP = @"^\s*(\S*?) (.*)";
|
||||
public static string EndPatternCMP = @"^\s*\)\s*$";
|
||||
|
||||
// Byte (1024-based) size comparisons
|
||||
#endregion
|
||||
|
||||
#region Byte (1024-based) size comparisons
|
||||
|
||||
public static 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);
|
||||
|
||||
// Byte (1000-based) size comparisons
|
||||
#endregion
|
||||
|
||||
#region Byte (1000-based) size comparisons
|
||||
|
||||
public static long KiloByte = 1000;
|
||||
public static long MegaByte = (long)Math.Pow(KiloByte, 2);
|
||||
public static long GigaByte = (long)Math.Pow(KiloByte, 2);
|
||||
public static long TeraByte = (long)Math.Pow(KiloByte, 2);
|
||||
public static long PetaByte = (long)Math.Pow(KiloByte, 2);
|
||||
|
||||
// Magic numbers as strings
|
||||
#endregion
|
||||
|
||||
#region Magic numbers as byte arrays
|
||||
|
||||
public static byte[] SevenZipSigBytes = new byte[] { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c };
|
||||
public static byte[] GzSigBytes = new byte[] { 0x1f, 0x8b };
|
||||
public static byte[] RarSigBytes = new byte[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
|
||||
public static byte[] RarFiveSigBytes = new byte[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 };
|
||||
public static byte[] TarSigBytes = new byte[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 };
|
||||
public static byte[] TarZeroSigBytes = new byte[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 };
|
||||
public static byte[] ZipSigBytes = new byte[] { 0x50, 0x4b, 0x03, 0x04 };
|
||||
public static byte[] ZipSigEmptyBytes = new byte[] { 0x50, 0x4b, 0x05, 0x06 };
|
||||
public static byte[] ZipSigSpannedBytes = new byte[] { 0x50, 0x4b, 0x07, 0x08 };
|
||||
|
||||
#endregion
|
||||
|
||||
#region Magic numbers as strings
|
||||
|
||||
public static string SevenZipSig = "377ABCAF271C";
|
||||
public static string GzSig = "1F8B";
|
||||
public static string RarSig = "526172211A0700";
|
||||
@@ -80,5 +119,51 @@ namespace SabreTools.Helper
|
||||
public static string ZipSig = "504B0304";
|
||||
public static string ZipSigEmpty = "504B0506";
|
||||
public static string ZipSigSpanned = "504B0708";
|
||||
|
||||
#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 };
|
||||
|
||||
/* (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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user