add basic binary fread

This commit is contained in:
2026-08-07 09:06:39 +09:00
parent f175be3938
commit 006ea5b62b
2 changed files with 67 additions and 18 deletions
+29 -11
View File
@@ -56,10 +56,10 @@ 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;
uint32_t sizeOfCompressed; // same as unCompression (cuz no compreesion)
uint32_t sizeOfUncompressed;
uint16_t lengthOfFileName;
uint16_t lengthOfExtraField;
// var[fileNameLength] fileName
// var[extraFieldLength] extraField
@@ -101,7 +101,6 @@ constexpr int LOCAL_FILE_HEADER_BYTE = 30;
constexpr int CENTRAL_DIRECTORY_BYTE = 46;
struct CentralDirectory {
uint32_t signature;
uint16_t versionMadeBy;
uint16_t versionNeededToExtract;
@@ -130,16 +129,26 @@ constexpr int LOCAL_FILE_HEADER_BYTE = 30;
end of central dir signature 4 bytes (0x0605 + 4b50)
number of this disk 2 bytes
// 중앙 디렉터리가 시작되는 디스크의 번호.
number of the disk with the
start of the central directory 2 bytes
// 이 디스크에 있는 중앙 디렉터리 항목의 수
total number of entries in the
central directory on this disk 2 bytes
// .ZIP 파일 내 전체 파일 수
total number of entries in
the central directory 2 bytes
size of the central directory 4 bytes
// 중앙 디렉터리가 시작되는 디스크 상에서 중앙 디렉터리 시작 지점의 오프셋
offset of start of central
directory with respect to
the starting disk number 4 bytes
.ZIP file comment length 2 bytes
.ZIP file comment (variable size)
*/
@@ -147,13 +156,22 @@ constexpr int LOCAL_FILE_HEADER_BYTE = 30;
struct EoCDRecord {
uint32_t signature;
// central directory end record을 포함하는 이 디스크의 번호
uint16_t diskNumber;
uint16_t diskNumber_CentralDirectoryStart;
uint16_t numOfCentralDirectory; // TODO : 이름 애매함.
uint16_t numEntries; // TODO : 이름 애매함.
uint32_t centralDirectorySize;
uint32_t centralDirectoryOffset;
uint16_t zipFileCommentLength;
// 중앙 디렉터리가 시작되는 디스크의 번호.
uint16_t diskNumber_CentralDirStart;
// 이 디스크에 있는 중앙 디렉터리 항목의 수
uint16_t numOfCentralDir;
// .ZIP 파일 내 전체 파일 수
uint16_t numOfEntries;
uint32_t SizeOfCentralDir;
uint32_t OffsetOfCentralDirOffset;
uint16_t LengthOfCommentLength;
// var[zipFileCommentLength] zipFileComment
};