mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Enums, Flags, Structs, FileTools] Add more archive stuff
This commit is contained in:
@@ -164,4 +164,66 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Archival
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Version of tool archive made by
|
||||||
|
/// </summary>
|
||||||
|
public enum ArchiveVersion
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compression method based on flag
|
||||||
|
/// </summary>
|
||||||
|
public enum CompressionMethod
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,4 +30,54 @@ namespace SabreTools.Helper
|
|||||||
RedumpSHA1 = 0x080,
|
RedumpSHA1 = 0x080,
|
||||||
RedumpSFV = 0x100,
|
RedumpSFV = 0x100,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines the archive general bit flags
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum GeneralPurposeBitFlag
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
ASCIIOrTextFile = 0x0001,
|
||||||
|
RecordLengthControl = 0x0002,
|
||||||
|
|
||||||
|
// Reserved and unused (SHOULD NOT BE USED)
|
||||||
|
Bit1 = 0x0002,
|
||||||
|
Bit2 = 0x0004,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -495,19 +495,19 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public struct ZipArchiveEntryStruct
|
public struct ZipArchiveEntryStruct
|
||||||
{
|
{
|
||||||
public short VersionMadeBy;
|
public ArchiveVersion VersionMadeBy;
|
||||||
public short VersionNeeded;
|
public ArchiveVersion VersionNeeded;
|
||||||
public short GeneralPurposeFlag;
|
public GeneralPurposeBitFlag GeneralPurposeBitFlag;
|
||||||
public short CompressionMethod;
|
public CompressionMethod CompressionMethod;
|
||||||
public short LastModFileTime;
|
public ushort LastModFileTime;
|
||||||
public short LastModFileDate;
|
public ushort LastModFileDate;
|
||||||
public int CRC;
|
public uint CRC;
|
||||||
public int CompressedSize;
|
public uint CompressedSize;
|
||||||
public int UncompressedSize;
|
public uint UncompressedSize;
|
||||||
public string FileName;
|
public string FileName;
|
||||||
public string ExtraField;
|
public string ExtraField;
|
||||||
public string Comment;
|
public string Comment;
|
||||||
public short InternalFileAttributes;
|
public InternalFileAttributes InternalFileAttributes;
|
||||||
public int ExternalFileAttributes;
|
public int ExternalFileAttributes;
|
||||||
public int RelativeOffset;
|
public int RelativeOffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ namespace SabreTools.Helper
|
|||||||
Console.WriteLine("Entry CRC: " + zaes.CRC.ToString("X8"));
|
Console.WriteLine("Entry CRC: " + zaes.CRC.ToString("X8"));
|
||||||
Console.WriteLine("Entry External File Attributes: " + zaes.ExternalFileAttributes);
|
Console.WriteLine("Entry External File Attributes: " + zaes.ExternalFileAttributes);
|
||||||
Console.WriteLine("Entry Extra Field: " + zaes.ExtraField.Length + " " + zaes.ExtraField);
|
Console.WriteLine("Entry Extra Field: " + zaes.ExtraField.Length + " " + zaes.ExtraField);
|
||||||
Console.WriteLine("Entry General Purpose Flag: " + zaes.GeneralPurposeFlag);
|
Console.WriteLine("Entry General Purpose Flag: " + zaes.GeneralPurposeBitFlag);
|
||||||
Console.WriteLine("Entry Internal File Attributes: " + zaes.InternalFileAttributes);
|
Console.WriteLine("Entry Internal File Attributes: " + zaes.InternalFileAttributes);
|
||||||
Console.WriteLine("Entry Last Modification File Date: " + zaes.LastModFileDate);
|
Console.WriteLine("Entry Last Modification File Date: " + zaes.LastModFileDate);
|
||||||
Console.WriteLine("Entry Last Modification File Time: " + zaes.LastModFileTime);
|
Console.WriteLine("Entry Last Modification File Time: " + zaes.LastModFileTime);
|
||||||
@@ -956,20 +956,20 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
br.BaseStream.Seek(position, SeekOrigin.Begin);
|
br.BaseStream.Seek(position, SeekOrigin.Begin);
|
||||||
br.ReadInt32(); // central file header signature
|
br.ReadInt32(); // central file header signature
|
||||||
zaes.VersionMadeBy = br.ReadInt16();
|
zaes.VersionMadeBy = (ArchiveVersion)br.ReadInt16();
|
||||||
zaes.VersionNeeded = br.ReadInt16();
|
zaes.VersionNeeded = (ArchiveVersion)br.ReadInt16();
|
||||||
zaes.GeneralPurposeFlag = br.ReadInt16();
|
zaes.GeneralPurposeBitFlag = (GeneralPurposeBitFlag)br.ReadInt16();
|
||||||
zaes.CompressionMethod = br.ReadInt16();
|
zaes.CompressionMethod = (CompressionMethod)br.ReadInt16();
|
||||||
zaes.LastModFileTime = br.ReadInt16();
|
zaes.LastModFileTime = br.ReadUInt16();
|
||||||
zaes.LastModFileDate = br.ReadInt16();
|
zaes.LastModFileDate = br.ReadUInt16();
|
||||||
zaes.CRC = br.ReadInt32();
|
zaes.CRC = br.ReadUInt32();
|
||||||
zaes.CompressedSize = br.ReadInt32();
|
zaes.CompressedSize = br.ReadUInt32();
|
||||||
zaes.UncompressedSize = br.ReadInt32();
|
zaes.UncompressedSize = br.ReadUInt32();
|
||||||
int fileNameLength = br.ReadInt16();
|
int fileNameLength = br.ReadInt16();
|
||||||
int extraFieldLength = br.ReadInt16();
|
int extraFieldLength = br.ReadInt16();
|
||||||
int fileCommentLength = br.ReadInt16();
|
int fileCommentLength = br.ReadInt16();
|
||||||
br.ReadInt16(); // disk number start
|
br.ReadInt16(); // disk number start
|
||||||
zaes.InternalFileAttributes = br.ReadInt16();
|
zaes.InternalFileAttributes = (InternalFileAttributes)br.ReadInt16();
|
||||||
zaes.ExternalFileAttributes = br.ReadInt32();
|
zaes.ExternalFileAttributes = br.ReadInt32();
|
||||||
zaes.RelativeOffset = br.ReadInt32();
|
zaes.RelativeOffset = br.ReadInt32();
|
||||||
zaes.FileName = Style.ConvertHex(BitConverter.ToString(br.ReadBytes(fileNameLength)));
|
zaes.FileName = Style.ConvertHex(BitConverter.ToString(br.ReadBytes(fileNameLength)));
|
||||||
|
|||||||
Reference in New Issue
Block a user