edit stdout log message
This commit is contained in:
+10
-10
@@ -19,8 +19,8 @@ bool MyZip::AddFileToZip(const std::string & strFileDiskPath, const std::string&
|
|||||||
std::ifstream fileIn(strFileDiskPath, std::ios::binary);
|
std::ifstream fileIn(strFileDiskPath, std::ios::binary);
|
||||||
if (!fileIn.is_open())
|
if (!fileIn.is_open())
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](AddFileToZip) Something went Worng...");
|
printf("[ ERROR ](AddFileToZip) Something went Worng...\r\n");
|
||||||
printf("fileIn open failed");
|
printf("fileIn open failed\r\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ bool MyZip::AddFileToZip(const std::string & strFileDiskPath, const std::string&
|
|||||||
// 파일 읽기
|
// 파일 읽기
|
||||||
if (!fileIn.read(pInBuffer, fileInSize))
|
if (!fileIn.read(pInBuffer, fileInSize))
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](AddFileToZip) Something went Worng...");
|
printf("[ ERROR ](AddFileToZip) Something went Worng...\r\n");
|
||||||
printf("fileIn read failed");
|
printf("fileIn read failed\r\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +80,8 @@ bool MyZip::FinalizeZip()
|
|||||||
iRet = fileOut.is_open();
|
iRet = fileOut.is_open();
|
||||||
if (!iRet)
|
if (!iRet)
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](FinalizeZip) Something went Worng...");
|
printf("[ ERROR ](FinalizeZip) Something went Worng...\r\n");
|
||||||
printf("FileOut open failed");
|
printf("FileOut open failed\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ bool MyZip::FinalizeZip()
|
|||||||
auto offset = fileOut.tellp();
|
auto offset = fileOut.tellp();
|
||||||
if (offset == static_cast<std::streampos>(-1))
|
if (offset == static_cast<std::streampos>(-1))
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](FinalizeZip) Failed to get offset");
|
printf("[ ERROR ](FinalizeZip) Failed to get offset\r\n");
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ bool MyZip::FinalizeZip()
|
|||||||
|
|
||||||
if (fileOut.fail())
|
if (fileOut.fail())
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](FinalizeZip) Disk write failed \n");
|
printf("[ ERROR ](FinalizeZip) Disk write failed\r\n");
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ bool MyZip::FinalizeZip()
|
|||||||
fileOut.write(reinterpret_cast<const char *>(&this->EOCDR), sizeof(this->EOCDR));
|
fileOut.write(reinterpret_cast<const char *>(&this->EOCDR), sizeof(this->EOCDR));
|
||||||
if (fileOut.fail())
|
if (fileOut.fail())
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](FinalizeZip) Disk write failed \n");
|
printf("[ ERROR ](FinalizeZip) Disk write failed\r\n");
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ bool MyZip::FinalizeZip()
|
|||||||
fileOut.close();
|
fileOut.close();
|
||||||
if (fileOut.fail())
|
if (fileOut.fail())
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](FinalizeZip) Failed to close/flush file (Maybe Disk full?)\n");
|
printf("[ ERROR ](FinalizeZip) Failed to close/flush file (Maybe Disk full?)\r\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-37
@@ -21,7 +21,7 @@ bool FileReader(MyZip &zip, std::string strInputPath, const std::filesystem::pat
|
|||||||
if (!filesystem::exists(pathObj))
|
if (!filesystem::exists(pathObj))
|
||||||
{
|
{
|
||||||
printf("[ERROR](FileReader) Something went Wrong..!! \r\n");
|
printf("[ERROR](FileReader) Something went Wrong..!! \r\n");
|
||||||
printf("[ERROR] File not found : %s ", pathObj.string().c_str());
|
printf("[ERROR] File not found : %s \r\n", pathObj.string().c_str());
|
||||||
|
|
||||||
bRet = false;
|
bRet = false;
|
||||||
}
|
}
|
||||||
@@ -130,69 +130,86 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
1. 폴더 순회구조의 문제
|
1. 폴더 순회구조의 문제
|
||||||
- 문제 : 전역변수(g_recursive_counter)및 함수(FileReader) 의 전역사용
|
- 문제 : 전역변수(g_recursive_counter)및 함수(FileReader) 의 전역사용
|
||||||
- 기대값 : 폴더 순회구조 또한 클래스화
|
- 기대값 : 폴더를 순회하는 로직 또한 클래스화
|
||||||
|
|
||||||
2. CentralDirectory 설계문제
|
2. CentralDirectory 설계문제
|
||||||
- 문제 : CentralDirectory 를 채우는 코드가 분산됨.
|
- 문제 : CentralDirectory 를 채우는 코드가 분산됨.
|
||||||
- 기대값 : 한 곳으로 집중.
|
- 기대값 : CentralDirectory 를 채우는 코드를 한 곳으로 집중.
|
||||||
|
|
||||||
3. 내부 상태 플래그 (bRet) 의 미구현
|
3. 내부 상태 플래그 (bRet) 의 미구현
|
||||||
- 현상 : 프로그램의 실패 상황 별 플래그값인 "bool bRet" 의 미구현
|
- 현상 : 프로그램의 실패 상황 별 플래그값인 "bool bRet" 의 사용처가 없음.
|
||||||
- 기대값 : 일반적인 error code 로써 동작하는 리턴 값으로 사용.
|
- 기대값 : 일반적인 error code 로써 동작하는 리턴 값으로 사용.
|
||||||
|
|
||||||
4. 예외처리 설계 및 구현의 부재
|
4. 예외처리 설계 및 구현의 부재
|
||||||
- 현상 : File I/O, 경로검사 등 일관된 형식의 예외처리와 Message 처리가 없음.
|
- 현상 : File I/O, 경로검사 등 일관된 형식의 예외처리와 Message 처리가 없음.
|
||||||
- 기대값 : 에러 조기발견
|
- 기대값 : 에러 조기발견 및 에러코드 가독성 향상
|
||||||
|
|
||||||
5. 별도 Unit Test 미구현
|
5. 별도 Unit Test 미구현
|
||||||
- 현상 : 프로젝트의 디버깅 및 테스트를 위해서는 프로그램의 전체 Work flow 를 따라가야 함.
|
- 현상 : 프로젝트의 디버깅 및 테스트를 위해서는 프로그램의 전체 Work flow 를 따라가야 함.
|
||||||
- 기대값 : 단일 기능 (예 : CRC 값 검증, Output File 테스트) 을 테스트 하기 위한 Unit Test 구현
|
- 기대값 : 단일 기능 (예 : CRC 값 검증, Output File 테스트) 을 테스트 하기 위한 Unit Test 구현
|
||||||
|
|
||||||
|
6. 사용자 편의 StdOut 부족
|
||||||
|
- 현상 : 출력 파일의 경로, 크기, 구조 등등 편의를 위한 Output 부족
|
||||||
|
- 기대값 : 굳이 파일을 직접 열지 않아도 출력결과를 확인 할 수 있음.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int iRet = 0;
|
int iRet = 0;
|
||||||
printf("==================== Hello Zip! ====================\r\n");
|
int iCounter = 0;
|
||||||
printf("=== Please enter Target Path ===\r\n");
|
|
||||||
printf("=== (FOR TEST, Input below) ===\r\n");
|
|
||||||
printf("=== (1 : File Test, 2 : Dir Test) ===\r\n");
|
|
||||||
printf("====================================================\r\n");
|
|
||||||
printf("Input Path: ");
|
|
||||||
|
|
||||||
string strInputPath;
|
while (true)
|
||||||
getline(cin, strInputPath);
|
|
||||||
|
|
||||||
|
|
||||||
// Testing input
|
|
||||||
if (strInputPath == "1")
|
|
||||||
strInputPath = INPUT_FILE_NAME;
|
|
||||||
else if (strInputPath == "2")
|
|
||||||
strInputPath = INPUT_DIR_NAME;
|
|
||||||
|
|
||||||
filesystem::path absPath = filesystem::absolute(strInputPath);
|
|
||||||
filesystem::path rootPath = absPath.parent_path();
|
|
||||||
|
|
||||||
// Main Zip archive method
|
|
||||||
MyZip zip;
|
|
||||||
if (!FileReader(zip, strInputPath, rootPath))
|
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](FileReader) Somthing went Wrong... \r\n");
|
if (++iCounter > 1)
|
||||||
iRet = -1;
|
printf("==================== Hello Zip! (%d th)=============\r\n", iCounter);
|
||||||
}
|
else
|
||||||
else
|
printf("==================== Hello Zip! ====================\r\n");
|
||||||
{
|
printf("=== Please enter Target Path ===\r\n");
|
||||||
if (!zip.FinalizeZip())
|
printf("=== (1 : File Test, 2 : Dir Test, q : Exit) ===\r\n");
|
||||||
|
printf("=== ===\r\n");
|
||||||
|
printf("=== [File Test : TestFiles/Target_File.txt] ===\r\n");
|
||||||
|
printf("=== [Dir Test : TestFiles/Target_Dir ] ===\r\n");
|
||||||
|
printf("====================================================\r\n");
|
||||||
|
printf("Input Path: ");
|
||||||
|
|
||||||
|
string strInputPath;
|
||||||
|
getline(cin, strInputPath);
|
||||||
|
|
||||||
|
|
||||||
|
// Testing input
|
||||||
|
if (strInputPath == "1")
|
||||||
|
strInputPath = INPUT_FILE_NAME;
|
||||||
|
else if (strInputPath == "2")
|
||||||
|
strInputPath = INPUT_DIR_NAME;
|
||||||
|
else if (strInputPath == "q")
|
||||||
|
break;
|
||||||
|
|
||||||
|
filesystem::path absPath = filesystem::absolute(strInputPath);
|
||||||
|
filesystem::path rootPath = absPath.parent_path();
|
||||||
|
|
||||||
|
// Main Zip archive method
|
||||||
|
MyZip zip;
|
||||||
|
if (!FileReader(zip, strInputPath, rootPath))
|
||||||
{
|
{
|
||||||
printf("[ ERROR ](Finallize) Somthing went Wrong... \r\n");
|
printf("[ ERROR ](FileReader) Somthing went Wrong... \r\n");
|
||||||
iRet = -1;
|
iRet = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("It Works Fine. \r\n");
|
if (!zip.FinalizeZip())
|
||||||
printf("==================== Good Bye Zip! =================\r\n");
|
{
|
||||||
iRet = 0;
|
printf("[ ERROR ](Finallize) Somthing went Wrong... \r\n");
|
||||||
|
iRet = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("It Works Fine. \r\n");
|
||||||
|
iRet = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("==================== Good Bye Zip! =================\r\n");
|
||||||
|
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user