상세 컨텐츠

본문 제목

ZIP 파일 구조 분석

멀티미디어/압축(Compress)

by cepiloth 2025. 5. 29. 16:37

본문

728x90

1. ZIP 파일 구조 개요

ZIP 파일은 크게 세 가지 주요 구조로 구성되어 있습니다:

  • Local File Header (로컬 파일 헤더)
  • Central Directory File Header (중앙 디렉토리 파일 헤더)
  • End of Central Directory Record (중앙 디렉토리 끝 레코드)

출처: ZIP File Format - Wikipedia

 


2. ZIP 파일 내부 구조 상세 분석

2.1 Local File Header (로컬 파일 헤더)

기본 크기: 30바이트 (가변 필드 제외)

필드명 크기 설명

local file header signature 4 bytes 0x04034b50 (고유 식별자)
version needed to extract 2 bytes 압축 해제에 필요한 최소 버전
general purpose bit flag 2 bytes 범용 비트 플래그
compression method 2 bytes 압축 방법
last mod file time 2 bytes 파일 최종 수정 시간
last mod file date 2 bytes 파일 최종 수정 날짜
crc-32 4 bytes CRC-32 체크섬
compressed size 4 bytes 압축된 파일 크기
uncompressed size 4 bytes 압축 해제된 파일 크기
file name length 2 bytes 파일명 길이
extra field length 2 bytes 추가 필드 길이
file name 가변 파일명 (UTF-8 또는 CP437 인코딩)
extra field 가변 추가 필드 데이터

2.2 Central Directory File Header (중앙 디렉토리 파일 헤더)

기본 크기: 46바이트 (가변 필드 제외)

필드명 크기 설명

central file header signature 4 bytes 0x02014b50 (고유 식별자)
version made by 2 bytes 생성한 ZIP 프로그램 버전
version needed to extract 2 bytes 압축 해제에 필요한 최소 버전
general purpose bit flag 2 bytes 범용 비트 플래그
compression method 2 bytes 압축 방법
last mod file time 2 bytes 파일 최종 수정 시간
last mod file date 2 bytes 파일 최종 수정 날짜
crc-32 4 bytes CRC-32 체크섬
compressed size 4 bytes 압축된 파일 크기
uncompressed size 4 bytes 압축 해제된 파일 크기
file name length 2 bytes 파일명 길이
extra field length 2 bytes 추가 필드 길이
file comment length 2 bytes 파일 주석 길이
disk number start 2 bytes 파일이 시작되는 디스크 번호
internal file attributes 2 bytes 내부 파일 속성
external file attributes 4 bytes 외부 파일 속성
relative offset of local header 4 bytes 로컬 헤더의 상대적 오프셋
file name 가변 파일명
extra field 가변 추가 필드 데이터
file comment 가변 파일 주석

2.3 End of Central Directory Record (중앙 디렉토리 끝 레코드)

기본 크기: 22바이트 (주석 제외)

필드명 크기 설명

end of central dir signature 4 bytes 0x06054b50 (고유 식별자)
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 현재 디스크의 중앙 디렉토리 엔트리 수
total number of entries in the central directory 2 bytes 전체 중앙 디렉토리 엔트리 수
size of the central directory 4 bytes 중앙 디렉토리 크기
offset of start of central directory 4 bytes 중앙 디렉토리 시작 오프셋
ZIP file comment length 2 bytes ZIP 파일 주석 길이
ZIP file comment 가변 ZIP 파일 주석

3. 참고 자료

압축 알고리즘 관련

ZIP 포맷 명세 및 라이브러리

4. 주요 수정 사항

  1. 구조명 정확성: "Central File Header" → "Central Directory File Header"로 수정
  2. 헤더명 통일: "End Header" → "End of Central Directory Record"로 정확한 명칭 사용
  3. 표 형식: 가독성을 위해 테이블 형식으로 정리
  4. 필드 설명 추가: 각 필드의 용도를 명확히 설명
  5. 인코딩 정보: 파일명 인코딩 방식(UTF-8, CP437) 정보 추가
  6. 링크 정리: 참고 자료 링크를 카테고리별로 체계적으로 정리
728x90
반응형

'멀티미디어 > 압축(Compress)' 카테고리의 다른 글

ZLIB 로 메모리에 압축 하기  (0) 2021.01.06
ZLIB 사용하여 메모리에 압축 풀기  (0) 2021.01.06
Lempel-Ziv 알고리즘  (0) 2018.09.04
GZIP 구조  (0) 2017.10.14
Run Length Encoding(1)  (0) 2017.10.14

관련글 더보기

댓글 영역