clean up files
This commit is contained in:
+60
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ZipDefine.h"
|
||||
#include "CRC.h"
|
||||
|
||||
#define INPUT_FILE_NAME "TestFiles/Target_File.txt"
|
||||
#define INPUT_DIR_NAME "TestFiles/Target_Dir"
|
||||
#define OUTPUT_FILE_NAME "Test_Out.zip"
|
||||
|
||||
class MyZip
|
||||
{
|
||||
private:
|
||||
std::ofstream fileOut;
|
||||
std::string strOutputPath;
|
||||
|
||||
// Zip Format struct
|
||||
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() : 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);
|
||||
EOCDR.signature = PK_SIGNATURE_EO_CDR;
|
||||
}
|
||||
|
||||
// Zip 에 파일 추가
|
||||
bool AddFileToZip(const std::string &strFileDiskPath, const std::string& strFileEntryPath);
|
||||
// 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);
|
||||
};
|
||||
Reference in New Issue
Block a user