Skip to content

Commit

Permalink
Use a cross-platform path separator (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnzbk authored Nov 1, 2024
1 parent f8430d3 commit 93f5060
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 138 deletions.
26 changes: 13 additions & 13 deletions tests/postprocess/ParCheckerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "YEncode.h"

static std::string currDir = FileSystem::GetCurrentDirectory().Str();
static std::string testDataDir = currDir + "/" + "parchecker";
static std::string testDataDir = currDir + PATH_SEPARATOR + "parchecker";

class ParCheckerMock : public ParChecker
{
Expand Down Expand Up @@ -67,7 +67,7 @@ void ParCheckerMock::Execute()

void ParCheckerMock::CorruptFile(const char* filename, int offset)
{
std::string fullfilename(m_workingDir + "/" + filename);
std::string fullfilename(m_workingDir + PATH_SEPARATOR + filename);

FILE* file = fopen(fullfilename.c_str(), FOPEN_RBP);
BOOST_REQUIRE(file != nullptr);
Expand All @@ -82,7 +82,7 @@ void ParCheckerMock::CorruptFile(const char* filename, int offset)

ParCheckerMock::EFileStatus ParCheckerMock::FindFileCrc(const char* filename, uint32* crc, SegmentList* segments)
{
std::string crcFileName = m_workingDir + "/crc.txt";
std::string crcFileName = m_workingDir + PATH_SEPARATOR + "crc.txt";
std::ifstream sm(crcFileName);
std::string smfilename, smcrc;
while (!sm.eof())
Expand All @@ -91,7 +91,7 @@ ParCheckerMock::EFileStatus ParCheckerMock::FindFileCrc(const char* filename, ui
if (smfilename == filename)
{
*crc = strtoul(smcrc.c_str(), nullptr, 16);
uint32 realCrc = CalcFileCrc((m_workingDir + "/" + filename).c_str());
uint32 realCrc = CalcFileCrc((m_workingDir + PATH_SEPARATOR + filename).c_str());
return *crc == realCrc ? ParChecker::fsSuccess : ParChecker::fsUnknown;
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(RepairNoNeedTest)
cmdOpts.push_back("ParRepair=no");
Options options(&cmdOpts, nullptr);

ParCheckerMock parChecker(currDir + "/" + "RepairNoNeedTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "RepairNoNeedTest");
parChecker.Execute();

BOOST_CHECK(parChecker.GetStatus() == ParChecker::psRepairNotNeeded);
Expand All @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(RepairPossibleTest)
cmdOpts.push_back("ParRepair=no");
Options options(&cmdOpts, nullptr);

ParCheckerMock parChecker(currDir + "/" + "RepairPossibleTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "RepairPossibleTest");
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.Execute();

Expand All @@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(RepairSuccessfulTest)
cmdOpts.push_back("ParRepair=yes");
Options options(&cmdOpts, nullptr);

ParCheckerMock parChecker(currDir + "/" + "RepairSuccessfulTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "RepairSuccessfulTest");
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.Execute();

Expand All @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(RepairFailedTest)
cmdOpts.push_back("ParRepair=no");
Options options(&cmdOpts, nullptr);

ParCheckerMock parChecker(currDir + "/" + "RepairSuccessfulTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "RepairSuccessfulTest");
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.CorruptFile("testfile.dat", 30000);
parChecker.CorruptFile("testfile.dat", 40000);
Expand All @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(QuickVerificationRepairNotNeededTest)

YEncode::init();

ParCheckerMock parChecker(currDir + "/" + "QuickVerificationRepairNotNeededTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "QuickVerificationRepairNotNeededTest");
parChecker.SetParQuick(true);
parChecker.Execute();

Expand All @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(QuickVerificationRepairSuccessfulTest)

YEncode::init();

ParCheckerMock parChecker(currDir + "/" + "QuickVerificationRepairSuccessfulTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "QuickVerificationRepairSuccessfulTest");
parChecker.SetParQuick(true);
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.Execute();
Expand All @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(QuickFullVerificationRepairSuccessfulTest)

YEncode::init();

ParCheckerMock parChecker(currDir + "/" + "QuickFullVerificationRepairSuccessfulTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "QuickFullVerificationRepairSuccessfulTest");
parChecker.SetParQuick(true);
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.CorruptFile("testfile.nfo", 100);
Expand All @@ -244,7 +244,7 @@ BOOST_AUTO_TEST_CASE(ParIgnoreExtDatTest)

Options options(&cmdOpts, nullptr);

ParCheckerMock parChecker(currDir + "/" + "ParIgnoreExtDatTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "ParIgnoreExtDatTest");
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.CorruptFile("testfile.dat", 30000);
parChecker.CorruptFile("testfile.dat", 40000);
Expand All @@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(ExtCleanupDiskDatTest)

Options options(&cmdOpts, nullptr);

ParCheckerMock parChecker(currDir + "/" + "ExtCleanupDiskDatTest");
ParCheckerMock parChecker(currDir + PATH_SEPARATOR + "ExtCleanupDiskDatTest");
parChecker.CorruptFile("testfile.dat", 20000);
parChecker.CorruptFile("testfile.dat", 30000);
parChecker.CorruptFile("testfile.dat", 40000);
Expand Down
30 changes: 15 additions & 15 deletions tests/postprocess/ParRenamerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "TestUtil.h"

static std::string currDir = FileSystem::GetCurrentDirectory().Str();
static std::string testDataDir = currDir + "/" + "parchecker";
static std::string testDataDir = currDir + PATH_SEPARATOR + "parchecker";

class ParRenamerMock : public ParRenamer
{
Expand Down Expand Up @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(RenameNotNeededTest)
cmdOpts.push_back("ParRename=yes");
Options options(&cmdOpts, nullptr);

ParRenamerMock parRenamer(currDir + "/" + "RenameNotNeededTest");
ParRenamerMock parRenamer(currDir + PATH_SEPARATOR + "RenameNotNeededTest");
parRenamer.Execute();

BOOST_CHECK(parRenamer.GetRenamedCount() == 0);
Expand All @@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(RenameSuccessfulTest)
cmdOpts.push_back("ParRename=yes");
Options options(&cmdOpts, nullptr);

std::string workingDir = currDir + "/" + "RenameSuccessfulTest";
std::string workingDir = currDir + PATH_SEPARATOR + "RenameSuccessfulTest";
std::string testFile = workingDir + "/testfile.dat";
std::string renamedTestFile = workingDir + "/123456";

Expand All @@ -98,10 +98,10 @@ BOOST_AUTO_TEST_CASE(DetectingMissingTest)
cmdOpts.push_back("ParRename=yes");
Options options(&cmdOpts, nullptr);

std::string workingDir = currDir + "/" + "DetectingMissingTest";
std::string testFile = workingDir + "/testfile.dat";
std::string testFileNfo = workingDir + "/testfile.nfo";
std::string renamedTestFile = workingDir + "/123456";
std::string workingDir = currDir + PATH_SEPARATOR + "DetectingMissingTest";
std::string testFile = workingDir + PATH_SEPARATOR + "testfile.dat";
std::string testFileNfo = workingDir + PATH_SEPARATOR + "testfile.nfo";
std::string renamedTestFile = workingDir + PATH_SEPARATOR + "123456";

ParRenamerMock parRenamer(workingDir);

Expand All @@ -121,11 +121,11 @@ BOOST_AUTO_TEST_CASE(RenameDupeParTest)
cmdOpts.push_back("ParRename=yes");
Options options(&cmdOpts, nullptr);

std::string workingDir = currDir + "/" + "RenameDupeParTest";
std::string testFile = workingDir + "/testfile.dat";
std::string renamedTestFile = workingDir + "/123456";
std::string testFilePar = workingDir + "/testfile.vol00+1.PAR2";
std::string renamedTestFilePar = workingDir + "/testfil2.par2";
std::string workingDir = currDir + PATH_SEPARATOR + "RenameDupeParTest";
std::string testFile = workingDir + PATH_SEPARATOR + "testfile.dat";
std::string renamedTestFile = workingDir + PATH_SEPARATOR + "123456";
std::string testFilePar = workingDir + PATH_SEPARATOR + "testfile.vol00+1.PAR2";
std::string renamedTestFilePar = workingDir + PATH_SEPARATOR + "testfil2.par2";

ParRenamerMock parRenamer(workingDir);

Expand All @@ -145,9 +145,9 @@ BOOST_AUTO_TEST_CASE(NoParExtensionTest)
cmdOpts.push_back("ParRename=yes");
Options options(&cmdOpts, nullptr);

std::string workingDir = currDir + "/" + "NoParExtensionTest";
std::string testFilePar = workingDir + "/testfile.par2";
std::string renamedTestFilePar = workingDir + "/testfile";
std::string workingDir = currDir + PATH_SEPARATOR + "NoParExtensionTest";
std::string testFilePar = workingDir + PATH_SEPARATOR + "testfile.par2";
std::string renamedTestFilePar = workingDir + PATH_SEPARATOR + "testfile";

ParRenamerMock parRenamer(workingDir);
BOOST_CHECK(FileSystem::MoveFile(testFilePar.c_str(), renamedTestFilePar.c_str()));
Expand Down
36 changes: 18 additions & 18 deletions tests/postprocess/RarReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@
#include "FileSystem.h"

static std::string currDir = FileSystem::GetCurrentDirectory().Str();
static std::string testDataDir = currDir + "/" + "rarrenamer";
static std::string testDataDir = currDir + PATH_SEPARATOR + "rarrenamer";

BOOST_AUTO_TEST_CASE(Rar3Test)
{
{
RarVolume volume((testDataDir + "/testfile3.part01.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3.part01.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetMultiVolume() == true);
BOOST_CHECK(volume.GetNewNaming() == true);
BOOST_CHECK(volume.GetVolumeNo() == 0);
}
{
RarVolume volume((testDataDir + "/testfile3.part02.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3.part02.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetMultiVolume() == true);
BOOST_CHECK(volume.GetNewNaming() == true);
BOOST_CHECK(volume.GetVolumeNo() == 1);
}
{
RarVolume volume((testDataDir + "/testfile3.part03.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3.part03.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(Rar3Test)
BOOST_AUTO_TEST_CASE(Rar5Test)
{
{
RarVolume volume((testDataDir + "/testfile5.part01.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5.part01.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 5);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(Rar5Test)
BOOST_CHECK(volume.GetVolumeNo() == 1);
}
{
RarVolume volume((testDataDir + "/testfile5.part03.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5.part03.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 5);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(Rar3OldNamingTest)
BOOST_CHECK(volume.GetVolumeNo() == 0);
}
{
RarVolume volume((testDataDir + "/testfile3oldnam.r00").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3oldnam.r00").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(Rar3OldNamingTest)
BOOST_AUTO_TEST_CASE(Rar3EncryptedDataTest)
{
{
RarVolume volume((testDataDir + "/testfile3encdata.part01.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3encdata.part01.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(Rar3EncryptedDataTest)
BOOST_CHECK(volume.GetVolumeNo() == 1);
}
{
RarVolume volume((testDataDir + "/testfile3encdata.part03.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3encdata.part03.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -146,23 +146,23 @@ BOOST_AUTO_TEST_CASE(Rar3EncryptedDataTest)
BOOST_AUTO_TEST_CASE(Rar5EncryptedDataTest)
{
{
RarVolume volume((testDataDir + "/testfile5encdata.part01.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5encdata.part01.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 5);
BOOST_CHECK(volume.GetMultiVolume() == true);
BOOST_CHECK(volume.GetNewNaming() == true);
BOOST_CHECK(volume.GetVolumeNo() == 0);
}
{
RarVolume volume((testDataDir + "/testfile5encdata.part02.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5encdata.part02.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 5);
BOOST_CHECK(volume.GetMultiVolume() == true);
BOOST_CHECK(volume.GetNewNaming() == true);
BOOST_CHECK(volume.GetVolumeNo() == 1);
}
{
RarVolume volume((testDataDir + "/testfile5encdata.part03.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5encdata.part03.rar").c_str());
BOOST_CHECK(volume.Read() == true);
BOOST_CHECK(volume.GetVersion() == 5);
BOOST_CHECK(volume.GetMultiVolume() == true);
Expand All @@ -174,14 +174,14 @@ BOOST_AUTO_TEST_CASE(Rar5EncryptedDataTest)
BOOST_AUTO_TEST_CASE(Rar3EcryptedNamesTest)
{
{
RarVolume volume((testDataDir + "/testfile3encnam.part01.rar").c_str());
RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3encnam.part01.rar").c_str());
BOOST_CHECK(volume.Read() == false);
BOOST_CHECK(volume.GetVersion() == 3);
BOOST_CHECK(volume.GetEncrypted() == true);
}

// {
// RarVolume volume((testDataDir + "/testfile3encnam.part01.rar").c_str());
// RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3encnam.part01.rar").c_str());
// volume.SetPassword("123");
// BOOST_CHECK(volume.Read() == true);
// BOOST_CHECK(volume.GetVersion() == 3);
Expand All @@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(Rar3EcryptedNamesTest)
// BOOST_CHECK(volume.GetVolumeNo() == 0);
// }
// {
// RarVolume volume((testDataDir + "/testfile3encnam.part02.rar").c_str());
// RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile3encnam.part02.rar").c_str());
// volume.SetPassword("123");
// BOOST_CHECK(volume.Read() == true);
// BOOST_CHECK(volume.GetVersion() == 3);
Expand All @@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(Rar3EcryptedNamesTest)
// BOOST_AUTO_TEST_CASE(Rar5EncryptedNames)
// {
// {
// RarVolume volume((testDataDir + "/testfile5encnam.part01.rar").c_str());
// RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5encnam.part01.rar").c_str());
// volume.SetPassword("123");
// BOOST_CHECK(volume.Read() == true);
// BOOST_CHECK(volume.GetVersion() == 5);
Expand All @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(Rar3EcryptedNamesTest)
// BOOST_CHECK(volume.GetVolumeNo() == 0);
// }
// {
// RarVolume volume((testDataDir + "/testfile5encnam.part02.rar").c_str());
// RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5encnam.part02.rar").c_str());
// volume.SetPassword("123");
// BOOST_CHECK(volume.Read() == true);
// BOOST_CHECK(volume.GetVersion() == 5);
Expand All @@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(Rar3EcryptedNamesTest)
// }

// {
// RarVolume volume((testDataDir + "/testfile5encnam.part01.rar").c_str());
// RarVolume volume((testDataDir + PATH_SEPARATOR + "testfile5encnam.part01.rar").c_str());
// BOOST_CHECK(volume.Read() == false);
// BOOST_CHECK(volume.GetVersion() == 5);
// BOOST_CHECK(volume.GetEncrypted() == true);
Expand Down
Loading

0 comments on commit 93f5060

Please sign in to comment.