mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-21 20:05:45 +02:00
Use execvp in fs::RecursiveDelete()
This commit is contained in:
@@ -42,6 +42,7 @@ public:
|
||||
void testSafeWriteToFile();
|
||||
void testCopyFileContents();
|
||||
void testNonExist();
|
||||
void testRecursiveDelete();
|
||||
};
|
||||
|
||||
static TestFileSys g_test_instance;
|
||||
@@ -56,6 +57,7 @@ void TestFileSys::runTests(IGameDef *gamedef)
|
||||
TEST(testSafeWriteToFile);
|
||||
TEST(testCopyFileContents);
|
||||
TEST(testNonExist);
|
||||
TEST(testRecursiveDelete);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -338,3 +340,32 @@ void TestFileSys::testNonExist()
|
||||
auto ifs = open_ifstream(path.c_str(), false);
|
||||
UASSERT(!ifs.good());
|
||||
}
|
||||
|
||||
void TestFileSys::testRecursiveDelete()
|
||||
{
|
||||
std::string dirs[2];
|
||||
dirs[0] = getTestTempDirectory() + DIR_DELIM "a";
|
||||
dirs[1] = dirs[0] + DIR_DELIM "b";
|
||||
|
||||
std::string files[2] = {
|
||||
dirs[0] + DIR_DELIM "file1",
|
||||
dirs[1] + DIR_DELIM "file2"
|
||||
};
|
||||
|
||||
for (auto &it : dirs)
|
||||
fs::CreateDir(it);
|
||||
for (auto &it : files)
|
||||
open_ofstream(it.c_str(), false).close();
|
||||
|
||||
for (auto &it : dirs)
|
||||
UASSERT(fs::IsDir(it));
|
||||
for (auto &it : files)
|
||||
UASSERT(fs::IsFile(it));
|
||||
|
||||
UASSERT(fs::RecursiveDelete(dirs[0]));
|
||||
|
||||
for (auto &it : dirs)
|
||||
UASSERT(!fs::IsDir(it));
|
||||
for (auto &it : files)
|
||||
UASSERT(!fs::IsFile(it));
|
||||
}
|
||||
|
Reference in New Issue
Block a user