mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Refactoring standarttester
This commit is contained in:
@ -142,12 +142,6 @@ public:
|
|||||||
void OpenDir(std::wstring sDir)
|
void OpenDir(std::wstring sDir)
|
||||||
{
|
{
|
||||||
m_sInputFolder = 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);
|
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(sDir, true);
|
||||||
for (std::vector<std::wstring>::iterator iter = arFiles.begin(); iter != arFiles.end(); iter++)
|
for (std::vector<std::wstring>::iterator iter = arFiles.begin(); iter != arFiles.end(); iter++)
|
||||||
@ -298,7 +292,6 @@ public:
|
|||||||
NSFile::CFileBinary::SaveToFile(sLogFile, sLogContent, true);
|
NSFile::CFileBinary::SaveToFile(sLogFile, sLogContent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GenerateDiff(const std::wstring strDirIn, const std::wstring strDirOut, const std::wstring strDiffs)
|
int GenerateDiff(const std::wstring strDirIn, const std::wstring strDirOut, const std::wstring strDiffs)
|
||||||
{
|
{
|
||||||
int nCountInPages = GetPagesCount(strDirIn);
|
int nCountInPages = GetPagesCount(strDirIn);
|
||||||
@ -521,6 +514,10 @@ class CConverter : public NSThreads::CBaseThread
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CInternalWorker* m_pInternal;
|
CInternalWorker* m_pInternal;
|
||||||
|
|
||||||
|
std::wstring m_input_dir;
|
||||||
|
std::wstring m_output_dir;
|
||||||
|
|
||||||
std::wstring m_file;
|
std::wstring m_file;
|
||||||
std::wstring m_folder_dst;
|
std::wstring m_folder_dst;
|
||||||
int m_format;
|
int m_format;
|
||||||
@ -537,15 +534,40 @@ public:
|
|||||||
Stop();
|
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()
|
virtual DWORD ThreadProc()
|
||||||
{
|
{
|
||||||
if (m_bDiffOnly)
|
if (m_bDiffOnly)
|
||||||
{
|
{
|
||||||
std::wstring strDirIn = m_file;
|
std::wstring strDirIn = GetOutputFile(L"", true);
|
||||||
std::wstring strDirOut = m_folder_dst;
|
std::wstring strDirOut = m_folder_dst;
|
||||||
|
|
||||||
std::wstring strDiffsMain = NSFile::GetDirectoryName(strDirOut) + L"/DIFF";
|
std::wstring strDiffs = GetOutputFile(L"DIFF");
|
||||||
std::wstring strDiffs = strDiffsMain + L"/" + NSFile::GetFileName(m_file);
|
|
||||||
|
|
||||||
int checkCode = m_pInternal->GenerateDiff(strDirIn, strDirOut, strDiffs);
|
int checkCode = m_pInternal->GenerateDiff(strDirIn, strDirOut, strDiffs);
|
||||||
|
|
||||||
@ -650,12 +672,10 @@ public:
|
|||||||
if (!m_pInternal->m_bIsStandard)
|
if (!m_pInternal->m_bIsStandard)
|
||||||
{
|
{
|
||||||
// смотрим разницу
|
// смотрим разницу
|
||||||
std::wstring strDirIn = NSFile::GetDirectoryName(m_file);
|
std::wstring strDirIn = GetOutputFile(L"", true);
|
||||||
std::wstring strDirOut = sDirectoryDst;
|
std::wstring strDirOut = sDirectoryDst;
|
||||||
|
|
||||||
std::wstring strDiffsMain = NSFile::GetDirectoryName(strDirOut) + L"/DIFF";
|
std::wstring strDiffs = GetOutputFile(L"DIFF");
|
||||||
std::wstring strDiffs = strDiffsMain + L"/" + NSFile::GetFileName(m_file);
|
|
||||||
|
|
||||||
checkCode = m_pInternal->GenerateDiff(strDirIn, strDirOut, strDiffs);
|
checkCode = m_pInternal->GenerateDiff(strDirIn, strDirOut, strDiffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,13 +693,18 @@ CConverter* CInternalWorker::GetNextConverter()
|
|||||||
|
|
||||||
CConverter* pConverter = new CConverter(this);
|
CConverter* pConverter = new CConverter(this);
|
||||||
pConverter->DestroyOnFinish();
|
pConverter->DestroyOnFinish();
|
||||||
|
|
||||||
|
pConverter->m_input_dir = m_sInputFolder;
|
||||||
|
pConverter->m_output_dir = m_sOutputFolder;
|
||||||
|
|
||||||
pConverter->m_file = m_files[m_nCurrent];
|
pConverter->m_file = m_files[m_nCurrent];
|
||||||
pConverter->m_bDiffOnly = m_bDiffOnly;
|
pConverter->m_bDiffOnly = m_bDiffOnly;
|
||||||
++m_nCurrent;
|
++m_nCurrent;
|
||||||
std::wstring sName = NSFile::GetFileName(pConverter->m_file);
|
std::wstring sName = NSFile::GetFileName(pConverter->m_file);
|
||||||
|
|
||||||
pConverter->m_folder_dst = m_sOutputFolder + L"/" + sName;
|
pConverter->m_folder_dst = pConverter->GetOutputFile();
|
||||||
NSDirectory::CreateDirectory(pConverter->m_folder_dst);
|
|
||||||
|
NSDirectory::CreateDirectories(pConverter->m_folder_dst);
|
||||||
|
|
||||||
if (m_bIsStandard)
|
if (m_bIsStandard)
|
||||||
NSFile::CFileBinary::Copy(pConverter->m_file, pConverter->m_folder_dst + L"/" + sName);
|
NSFile::CFileBinary::Copy(pConverter->m_file, pConverter->m_folder_dst + L"/" + sName);
|
||||||
|
|||||||
Reference in New Issue
Block a user