fill basic ZIP header format

This commit is contained in:
2026-08-07 10:26:20 +09:00
parent 1d5dd34bed
commit 969bce540e
2 changed files with 75 additions and 20 deletions
+16 -12
View File
@@ -2,6 +2,11 @@
#include <cstdint>
const static uint32_t PK_SIGNATURE_LF_HEADER = 0x04034b50; // PK + 0x0403
const static uint32_t PK_SIGNATURE_CENT_DIR = 0x02014b50; // PK + 0x0201
const static uint32_t PK_SIGNATURE_EO_CDR = 0x06054b50; // PK + 0x0605
const static uint16_t METHOD_UNCOMPRESSED = 0;
/** Overall .ZIP file format:
[local file header 1] -> "PK" + 0x4b50 + ...
@@ -61,8 +66,8 @@ constexpr int LOCAL_FILE_HEADER_BYTE = 30;
uint16_t lengthOfFileName;
uint16_t lengthOfExtraField;
// var[fileNameLength] fileName
// var[extraFieldLength] extraField
// var[lengthOfFileName] fileName
// var[lengthOfExtraField] extraField
};
/** Central directory structure:
@@ -109,20 +114,20 @@ constexpr int LOCAL_FILE_HEADER_BYTE = 30;
uint16_t lastModTime; // 압축 시점의 시간 (1980년 기준 시간)
uint16_t lastModDate; // 압축 시점의 날짜 (1980년 기준 연도)
uint32_t crc32;
uint32_t compressedSize; // same as unCompression (cuz no compreesion)
uint32_t unCompressedSize;
uint16_t fileNameLength;
uint16_t extraFieldLength;
uint16_t fileCommentLength;
uint32_t sizeOfCompressed; // same as unCompression (cuz no compreesion)
uint32_t sizeOfUncompressed;
uint16_t lengthOfFileName;
uint16_t lengthOfExtraField;
uint16_t lengthOfFileComment;
uint16_t diskNumStart;
uint16_t attributeInternal;
uint32_t attributeExternal;
uint32_t offsetLocalHeader;
// var[fileNameLength] fileName
// var[extraFieldLength] extraField
// var[fileCommentLength] fileComment
// var[lengthOfFileName] fileName
// var[lengthOfExtraField] extraField
// var[lengthOfFileComment] fileComment
};
/** End of central directory record:
@@ -168,12 +173,11 @@ constexpr int LOCAL_FILE_HEADER_BYTE = 30;
// .ZIP 파일 내 전체 파일 수
uint16_t numOfEntries;
uint32_t SizeOfCentralDir;
uint32_t OffsetOfCentralDirOffset;
uint16_t LengthOfCommentLength;
// var[zipFileCommentLength] zipFileComment
// var[LengthOfCommentLength] zipFileComment
};
#pragma pack(pop)