patterns: Minor cleanup to zip pattern (#59)

* Use spaces instead of tabs in zip.hexpat

* patterns: minor cleanup to ZIP pattern

- Remove empty and unused CentralDirectoryEntry struct.
- Shorten the comment of CentralDirectoryFileHeader.fileOffset. It was so
  long that the tooltip overflowed my screen, and didn't really add much
  information.
- Small whitespace changes.
This commit is contained in:
Nicolás Alvarez
2022-11-14 18:46:28 -03:00
committed by GitHub
parent de0e089165
commit a9ada89bd0

View File

@@ -2,45 +2,41 @@
#include <std/mem.pat> #include <std/mem.pat>
struct EndOfCentralDirectory{ struct EndOfCentralDirectory {
u32 headerSignature [[color("00000000")]]; u32 headerSignature [[color("00000000")]];
u16 diskNum [[comment("Number of this disk "), name("Disk Number")]]; u16 diskNum [[comment("Number of this disk "), name("Disk Number")]];
u16 diskStart [[comment("Disk where central directory starts "), name("Central Directory Disk Number")]]; u16 diskStart [[comment("Disk where central directory starts "), name("Central Directory Disk Number")]];
u16 CDRCount [[comment("Number of central directory records on this disk"), name("Central Directory Entries")]]; u16 CDRCount [[comment("Number of central directory records on this disk"), name("Central Directory Entries")]];
u16 CentralDirectoryRecordCount [[comment("Total number of entries in the central directory"), name("Total Central Directory Entries")]]; u16 CentralDirectoryRecordCount [[comment("Total number of entries in the central directory"), name("Total Central Directory Entries")]];
u32 CDSize [[comment("Size of central directory (bytes)"), name("Central Directory Size")]]; u32 CDSize [[comment("Size of central directory (bytes)"), name("Central Directory Size")]];
u32 CDOffset [[comment("Offset of start of central directory, relative to start of archive"), name("Central Directory Offset")]]; u32 CDOffset [[comment("Offset of start of central directory, relative to start of archive"), name("Central Directory Offset")]];
u16 commentLength [[color("00000000")]]; u16 commentLength [[color("00000000")]];
char coment[commentLength] [[name("Comment")]]; char coment[commentLength] [[name("Comment")]];
}; };
EndOfCentralDirectory fileInfo @ std::mem::find_sequence(0,0x50,0x4B,0x05,0x06) [[name("End of Central Directory Record")]]; EndOfCentralDirectory fileInfo @ std::mem::find_sequence(0,0x50,0x4B,0x05,0x06) [[name("End of Central Directory Record")]];
struct CentralDirectoryEntry{ struct CentralDirectoryFileHeader {
u32 headerSignature [[color("00000000")]];
}; u16 versionMade [[comment("Version file made by")]];
u16 versionExtract [[comment("Minimum version needed to extract")]];
struct CentralDirectoryFileHeader{ u16 generalFlag [[comment("General purpose bit flag"), color("00000000")]];
u32 headerSignature [[color("00000000")]]; u16 compressionMethod;
u16 versionMade [[comment("Version file made by")]]; u16 fileLastModifyTime [[comment("File last modification time")]];
u16 versionExtract [[comment("Minimum version needed to extract")]]; u16 fileLastModifyDate [[comment("File last modification date")]];
u16 generalFlag [[comment("General purpose bit flag"), color("00000000")]]; u32 crc32 [[comment("CRC-32 of uncompressed data"), color("00000000")]];
u16 compressionMethod; u32 compressedSize;
u16 fileLastModifyTime [[comment("File last modification time")]]; u32 uncompressedSize;
u16 fileLastModifyDate [[comment("File last modification date")]]; u16 fileNameLength [[color("00000000")]];
u32 crc32 [[comment("CRC-32 of uncompressed data"), color("00000000")]]; u16 extraFieldLength [[color("00000000")]];
u32 compressedSize; u16 fileCommentLength [[color("00000000")]];
u32 uncompressedSize; u16 diskNumber [[comment("Disk number where file starts")]];
u16 fileNameLength [[color("00000000")]]; u16 internalFileAttributes;
u16 extraFieldLength [[color("00000000")]]; u32 externalFileAttributes;
u16 fileCommentLength [[color("00000000")]]; u32 fileOffset [[comment("Offset of local file header, relative to the start of the first disk on which the file occurs.")]];
u16 diskNumber [[comment("Disk number where file starts ")]]; char fileName[fileNameLength];
u16 internalFileAttributes; u8 extraField[extraFieldLength];
u32 externalFileAttributes; char comment[fileCommentLength];
u32 fileOffset [[comment("Relative offset of local file header. This is the number of bytes between the start of the first disk on which the file occurs, and the start of the local file header. This allows software reading the central directory to locate the position of the file inside the ZIP file.")]];
char fileName[fileNameLength];
u8 extraField[extraFieldLength];
char comment[fileCommentLength];
}; };
CentralDirectoryFileHeader centralDirHeaders[fileInfo.CDRCount] @ (fileInfo.CDOffset) [[name("Files")]]; CentralDirectoryFileHeader centralDirHeaders[fileInfo.CDRCount] @ (fileInfo.CDOffset) [[name("Files")]];