Skip to content

Commit

Permalink
Refactoring standarttester
Browse files Browse the repository at this point in the history
  • Loading branch information
K0R0L committed Feb 4, 2025
1 parent a33743c commit 45da53e
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions Test/Applications/StandardTester/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ class CInternalWorker
void OpenDir(std::wstring sDir)
{
m_sInputFolder = sDir;
if (m_bDiffOnly)
{
m_files = NSDirectory::GetDirectories(m_sInputFolder);
m_nCount = (int)m_files.size();
return;
}

std::vector<std::wstring> arFiles = NSDirectory::GetFiles(sDir, true);
for (std::vector<std::wstring>::iterator iter = arFiles.begin(); iter != arFiles.end(); iter++)
Expand Down Expand Up @@ -298,7 +292,6 @@ class CInternalWorker
NSFile::CFileBinary::SaveToFile(sLogFile, sLogContent, true);
}


int GenerateDiff(const std::wstring strDirIn, const std::wstring strDirOut, const std::wstring strDiffs)
{
int nCountInPages = GetPagesCount(strDirIn);
Expand Down Expand Up @@ -521,6 +514,10 @@ class CConverter : public NSThreads::CBaseThread
{
public:
CInternalWorker* m_pInternal;

std::wstring m_input_dir;
std::wstring m_output_dir;

std::wstring m_file;
std::wstring m_folder_dst;
int m_format;
Expand All @@ -537,15 +534,40 @@ class CConverter : public NSThreads::CBaseThread
Stop();
}

std::wstring GetOutputFile(const std::wstring& sFolderAddon = L"", const bool& isStandart = false)
{
std::wstring input_dir = m_input_dir;
NSStringUtils::string_replace(input_dir, L"\\", L"/");

std::wstring input_file = m_file;
NSStringUtils::string_replace(input_file, L"\\", L"/");

std::wstring output_dir = isStandart ? (m_input_dir + L"/../out/master") : (m_output_dir + L"/");
if (!sFolderAddon.empty())
output_dir += (sFolderAddon + L"/");

NSStringUtils::string_replace(output_dir, L"\\", L"/");
NSStringUtils::string_replace(output_dir, L"//", L"/");

std::wstring output_file = output_dir + input_file.substr(input_dir.length());

NSStringUtils::string_replace(output_file, L"//", L"/");

#ifdef _WIN32
NSStringUtils::string_replace(output_file, L"/", L"\\");
#endif

return output_file;
}

virtual DWORD ThreadProc()
{
if (m_bDiffOnly)
{
std::wstring strDirIn = m_file;
std::wstring strDirIn = GetOutputFile(L"", true);
std::wstring strDirOut = m_folder_dst;

std::wstring strDiffsMain = NSFile::GetDirectoryName(strDirOut) + L"/DIFF";
std::wstring strDiffs = strDiffsMain + L"/" + NSFile::GetFileName(m_file);
std::wstring strDiffs = GetOutputFile(L"DIFF");

int checkCode = m_pInternal->GenerateDiff(strDirIn, strDirOut, strDiffs);

Expand Down Expand Up @@ -650,12 +672,10 @@ class CConverter : public NSThreads::CBaseThread
if (!m_pInternal->m_bIsStandard)
{
// смотрим разницу
std::wstring strDirIn = NSFile::GetDirectoryName(m_file);
std::wstring strDirIn = GetOutputFile(L"", true);
std::wstring strDirOut = sDirectoryDst;

std::wstring strDiffsMain = NSFile::GetDirectoryName(strDirOut) + L"/DIFF";
std::wstring strDiffs = strDiffsMain + L"/" + NSFile::GetFileName(m_file);

std::wstring strDiffs = GetOutputFile(L"DIFF");
checkCode = m_pInternal->GenerateDiff(strDirIn, strDirOut, strDiffs);
}

Expand All @@ -673,13 +693,18 @@ CConverter* CInternalWorker::GetNextConverter()

CConverter* pConverter = new CConverter(this);
pConverter->DestroyOnFinish();

pConverter->m_input_dir = m_sInputFolder;
pConverter->m_output_dir = m_sOutputFolder;

pConverter->m_file = m_files[m_nCurrent];
pConverter->m_bDiffOnly = m_bDiffOnly;
++m_nCurrent;
std::wstring sName = NSFile::GetFileName(pConverter->m_file);

pConverter->m_folder_dst = m_sOutputFolder + L"/" + sName;
NSDirectory::CreateDirectory(pConverter->m_folder_dst);
pConverter->m_folder_dst = pConverter->GetOutputFile();

NSDirectory::CreateDirectories(pConverter->m_folder_dst);

if (m_bIsStandard)
NSFile::CFileBinary::Copy(pConverter->m_file, pConverter->m_folder_dst + L"/" + sName);
Expand Down

0 comments on commit 45da53e

Please sign in to comment.