make class works. need to be tested

This commit is contained in:
2026-08-31 14:59:10 +09:00
parent aaa3ae2f8d
commit 1b0cf51c38
4 changed files with 180 additions and 119 deletions
+24 -9
View File
@@ -8,6 +8,8 @@
#include "CRC.h"
#define OUTPUT_FILE_NAME "MyZip.zip"
#define INPUT_FILE_NAME "Target_File.txt"
#define INPUT_DIR_NAME "Target_File"
class MyZip
{
@@ -16,30 +18,43 @@ private:
std::string strOutputPath;
// Zip Format struct
CentralDirectory CentDir{};
EoCDRecord EOCDR{};
struct ArchivedEntry
{
CentralDirectory header;
std::string fileName;
// TODO : 아래 기본값 어디서 채울 지 고민 (GetFiiled or 여기서)
ArchivedEntry(CentralDirectory cdh, std::string name) : header(cdh), fileName(name)
{
header.signature = PK_SIGNATURE_CENT_DIR;
header.versionMadeBy = 0; // Temp
header.versionNeededToExtract = 0; // Temp
header.generalBitFlag = 0; // Temp
header.compressionMethod = METHOD_UNCOMPRESSED;
}
};
std::vector<ArchivedEntry> vecEntries;
public:
MyZip(std::string strfilePath)
: strOutputPath(strfilePath)
MyZip() : strOutputPath(std::string(OUTPUT_FILE_NAME))
{
fileOut = std::ofstream(strOutputPath, std::ios::binary);
EOCDR.signature = PK_SIGNATURE_EO_CDR;
}
MyZip(const std::string& strfilePath) : strOutputPath(strfilePath)
{
fileOut = std::ofstream(strOutputPath, std::ios::binary);
CentDir.signature = PK_SIGNATURE_CENT_DIR;
EOCDR.signature = PK_SIGNATURE_EO_CDR;
CentDir.versionMadeBy = 0; // Temp
CentDir.versionNeededToExtract = 0; // Temp
CentDir.generalBitFlag = 0; // Temp
CentDir.compressionMethod = METHOD_UNCOMPRESSED;
}
// Zip 에 파일 추가
bool AddFileToZip(const std::string &strFilePath);
// Zip 마무리
bool FinalizeZip();
// Header Functions
void FillLocalFileHeader(LocalFileHeader &targetLF, const uint32_t targetCRC, const uint32_t targetSize, const uint16_t targetNameLeng);
CentralDirectory GetFilledCentDirHeader(CentralDirectory &targetCDH, const uint32_t targetCRC, const uint32_t targetSize, const uint16_t targetNameLeng);
};