mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
77 lines
1.4 KiB
Rust
77 lines
1.4 KiB
Rust
#pragma MIME application/gzip
|
|
|
|
#include <type/time.pat>
|
|
#include <type/size.pat>
|
|
#include <std/mem.pat>
|
|
|
|
bitfield Flags {
|
|
FTEXT : 1;
|
|
FHCRC : 1;
|
|
FEXTRA : 1;
|
|
FNAME : 1;
|
|
FCOMMENT : 1;
|
|
padding : 3;
|
|
} [[right_to_left]];
|
|
|
|
bitfield ExtraFlags {
|
|
padding : 1;
|
|
maximumCompression : 1;
|
|
fastestCompression : 1;
|
|
padding : 5;
|
|
};
|
|
|
|
enum CompressionMethod : u8 {
|
|
Reserved = 0 ... 7,
|
|
Deflate = 8
|
|
};
|
|
|
|
enum OperatingSystemID : u8 {
|
|
FATFileSystem = 0x00,
|
|
Amiga = 0x01,
|
|
VMS = 0x02,
|
|
Unix = 0x03,
|
|
VM_CMS = 0x04,
|
|
AtariTOS = 0x05,
|
|
HPFSFileSystem = 0x06,
|
|
Macintosh = 0x07,
|
|
ZSystem = 0x08,
|
|
CP_M = 0x09,
|
|
TOPS_20 = 0x0A,
|
|
NTFSFileSystem = 0x0B,
|
|
QDOS = 0x0C,
|
|
AcordRISCOS = 0x0D,
|
|
Unknown = 0xFF
|
|
};
|
|
|
|
struct GZip {
|
|
u16 signature;
|
|
CompressionMethod compressionMethod;
|
|
Flags flags;
|
|
type::time32_t modificationTime;
|
|
ExtraFlags extraFlags;
|
|
OperatingSystemID operatingSystemId;
|
|
|
|
if (flags.FEXTRA) {
|
|
u16 extraLength;
|
|
u8 extraField[extraLength];
|
|
}
|
|
|
|
if (flags.FNAME) {
|
|
char originalFileName[];
|
|
}
|
|
|
|
if (flags.FCOMMENT) {
|
|
char comment[];
|
|
}
|
|
|
|
if (flags.FHCRC) {
|
|
u16 crc16;
|
|
}
|
|
|
|
u8 data[while($ < std::mem::size() - 8)] [[sealed]];
|
|
|
|
u32 crc32;
|
|
type::Size<u32> isize;
|
|
};
|
|
|
|
GZip gzip @ 0x00; |