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
+30 -19
View File
@@ -14,19 +14,22 @@
static uint32_t g_recursive_counter = 0;
bool ZipArchiver(std::string strInputPath)
bool ZipArchiver(std::string strInputPath, bool bIsFinal = false)
{
MyZip myZIP(strInputPath);
MyZip zip;
bool bRet = false;
myZIP.AddFileToZip();
bRet = zip.AddFileToZip(strInputPath);
if(bIsFinal)
bRet = zip.FinalizeZip();
return false;
return bRet;
}
bool FileReader(std::string strInputPath)
{
using namespace std;
bool iRet = true;
bool bRet = true;
// path class obj 생성.
filesystem::path pathObj(strInputPath);
@@ -37,7 +40,8 @@ bool FileReader(std::string strInputPath)
string strDbg = "[ERROR] File not found : " + pathObj.string();
strDbg += "\r\n";
OutputDebugStringA(strDbg.c_str());
iRet = false;
bRet = false;
}
enum class eFILETYPE
{
@@ -50,12 +54,14 @@ bool FileReader(std::string strInputPath)
else if (filesystem::is_regular_file(pathObj)) eFileDist = eFILETYPE::isFile;
else eFileDist = eFILETYPE::ETC;
const filesystem::path& rootPath = pathObj;
switch (eFileDist)
{
// case 1 : input file
case eFILETYPE::isFile:
{
iRet = ZipArchiver(pathObj.string());
bool bIsFinal = g_recursive_counter > 0 ? false : true;
bRet = ZipArchiver(pathObj.string(), bIsFinal );
break;
}
@@ -68,37 +74,37 @@ bool FileReader(std::string strInputPath)
{
// get entry one by one
const filesystem::directory_entry& currentEntry = *itrDir;
const filesystem::path& currentPath = currentEntry.path();
const filesystem::path& currentAbsPath = currentEntry.path();
if (filesystem::is_directory(currentEntry))
{
// 있으면 좋을거같아서 만든 변수 "g_recursive_counter"
g_recursive_counter++;
// TODO : export to debugging log function
string strDbg = "[INFO] Current Entry (Dir)\t: " + currentPath.string();
string strDbg = "[INFO] Current Entry (Dir)\t: " + currentAbsPath.string();
strDbg += "\t Counter : " + to_string(g_recursive_counter);
strDbg += "\r\n";
OutputDebugStringA(strDbg.c_str());
// recursive traversal
iRet = FileReader(currentPath.string());
bRet = FileReader(currentAbsPath.string());
g_recursive_counter--;
}
else if (filesystem::is_regular_file(currentEntry))
{
// TODO : export to debugging log function
string strDbg = "[INFO] Current Entry (File)\t: " + currentPath.string();
string strDbg = "[INFO] Current Entry (File)\t: " + currentAbsPath.string();
strDbg += "\t Counter : " + to_string(g_recursive_counter);
strDbg += "\r\n";
OutputDebugStringA(strDbg.c_str());
// archiving file
iRet = ZipArchiver(currentPath.string());
auto relativePath = filesystem::relative(currentAbsPath, rootPath);
bRet = ZipArchiver(relativePath.string());
}
else
{
// TODO : 근데 애초에 제 3의 Type 이 있나? (여기 의미 있는건가?)
OutputDebugStringA("[ERROR] Wrong Type of File");
iRet = false;
bRet = false;
}
// step forward entry
@@ -114,24 +120,29 @@ bool FileReader(std::string strInputPath)
string strErr = "[ERROR] Something went Wrong..!!";
OutputDebugStringA(strErr.c_str());
iRet = false;
bRet = false;
break;
}
default:
break;
};
if(bRet)
{
bRet = ZipArchiver(strInputPath, true);
}
// TODO : 실패 상황 별 다른 코드 부여 + 코드 별 처리 어떻게 할 건지?
return iRet;
return bRet;
}
int main()
int main(int argc, char* argv[])
{
std::printf("==================== Hello Zip! ====================\r\n");
int iRet = 0;
// Main Zip archive method
if (!FileReader(INPUT_FILE_NAME))
if (!FileReader(std::string(INPUT_FILE_NAME)))
{
iRet = -1;
std::printf("[ ERROR ] Somthing went Wrong... \r\n");