zip 파일 포맷은 Local Directory와 Central Directory로 구분됩니다. zip 라이브러리는 Central Directory부터 읽어서, 즉 파일의 맨뒤부터 읽어서, offset 정보를 얻어내고, 압축 해제하는 구조를 가집니다. 따라서 기존 exe 파일 뒤에 압축 데이터를 결합하고, exe 파일 자체를 압축 해제하면 압축 데이터 부분만 추출해낼 수 있습니다.
exe와 zip 데이터가 결합된 프로그램을 Self Extractor라고 부릅니다.
참고 파일:
이전 폴더 압축 및 폴더 해제 관련 클래스 소스
Extractor.cpp 파일
// Extractor.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "UnzipCTL.h"
int main(int argc, char* argv[])
{
UnzipCTL ctl(argv[0]);
ctl.extractall("mydata");
return 0;
}
extractor_maker.cpp 파일
// extractor_maker.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "ZipCTL.h"
int _tmain(int argc, _TCHAR* argv[])
{
// 특정 폴더의 파일 목록을 읽어온다.
FolderList::ZIP_FLIST flist;
FolderList fn;
fn("C:\\NVIDIA",flist);
// 압축 데이터 생성-기존 파일 뒤에 압축 데이터 결합
ZipCTL ctl("Extractor.exe",APPEND_STATUS_CREATEAFTER);
ctl.make("C:\\NVIDIA",flist);
return 0;
}