{
CynaraMask mask;
- FileOperations::clear(CynaraTestConsts::SERVICE_PLUGINS_DIR);
+ FileOperations::removeDirFiles(CynaraTestConsts::SERVICE_PLUGINS_DIR);
for (const auto &dir : pluginDirectories)
- FileOperations::copyDir(dir.c_str(), CynaraTestConsts::SERVICE_PLUGINS_DIR);
+ FileOperations::copyCynaraFiles(dir.c_str(), CynaraTestConsts::SERVICE_PLUGINS_DIR);
}
{
CynaraMask mask;
- clear(m_dbSaveDir);
+ removeDirFiles(m_dbSaveDir);
removeDirIfExists(m_dbSaveDir);
- clear(m_pluginsSaveDir);
+ removeDirFiles(m_pluginsSaveDir);
removeDirIfExists(m_pluginsSaveDir);
removeDirIfExists(m_saveDir);
m_dbPresent = dirExists(CynaraTestConsts::DB_DIR);
if (m_dbPresent) {
makeDir(m_dbSaveDir);
- copyDir(CynaraTestConsts::DB_DIR, m_dbSaveDir);
+ copyCynaraFiles(CynaraTestConsts::DB_DIR, m_dbSaveDir);
}
makeDir(m_pluginsSaveDir);
- copyDir(CynaraTestConsts::SERVICE_PLUGINS_DIR, m_pluginsSaveDir);
+ copyCynaraFiles(CynaraTestConsts::SERVICE_PLUGINS_DIR, m_pluginsSaveDir);
}
void CynaraTestEnv::restore()
{
CynaraMask mask;
- clear(CynaraTestConsts::DB_DIR);
+ removeDirFiles(CynaraTestConsts::DB_DIR);
if (m_dbPresent)
- copyDir(m_dbSaveDir, CynaraTestConsts::DB_DIR);
+ copyCynaraFiles(m_dbSaveDir, CynaraTestConsts::DB_DIR);
else
removeDirIfExists(CynaraTestConsts::DB_DIR);
- clear(CynaraTestConsts::SERVICE_PLUGINS_DIR);
- copyDir(m_pluginsSaveDir, CynaraTestConsts::SERVICE_PLUGINS_DIR);
+ removeDirFiles(CynaraTestConsts::SERVICE_PLUGINS_DIR);
+ copyCynaraFiles(m_pluginsSaveDir, CynaraTestConsts::SERVICE_PLUGINS_DIR);
- clear(m_dbSaveDir);
+ removeDirFiles(m_dbSaveDir);
removeDirIfExists(m_dbSaveDir);
- clear(m_pluginsSaveDir);
+ removeDirFiles(m_pluginsSaveDir);
removeDirIfExists(m_pluginsSaveDir);
removeDirIfExists(m_saveDir);
}
namespace FileOperations
{
-static int removeContents(const char *fpath, const struct stat * /*sb*/,
+static int removeFile(const char *fpath, const struct stat * /*sb*/,
int tflag, struct FTW * /*ftwbuf*/)
{
if (tflag == FTW_F)
return true;
}
-void copyFile(const std::string &src, const std::string &dst)
+void copyCynaraFile(const std::string &src, const std::string &dst)
{
using PwBufPtr = CStringPtr;
int inFd = TEMP_FAILURE_RETRY(open(src.c_str(), O_RDONLY));
RUNNER_ASSERT_ERRNO_MSG(ret != -1, "sendfile failed");
}
-void copyDir(const std::string &source, const std::string &destination)
+void copyCynaraFiles(const std::string &source, const std::string &destination)
{
DIR *dirPtr = nullptr;
struct dirent *direntPtr;
continue;
std::string tempDest = destination + "/" + direntPtr->d_name;
std::string tempSrc = source + "/" + direntPtr->d_name;
- copyFile(tempSrc, tempDest);
+ copyCynaraFile(tempSrc, tempDest);
}
}
"Unable to make " << directory << " test directory");
}
-void clear(const std::string &dir)
+void removeDirFiles(const std::string &dir)
{
- int ret = nftw(dir.c_str(), removeContents, 2, FTW_DEPTH | FTW_PHYS);
+ int ret = nftw(dir.c_str(), removeFile, 2, FTW_DEPTH | FTW_PHYS);
if (ret == -1)
RUNNER_ASSERT_ERRNO_MSG(errno == ENOENT, "nftw failed");
}
{
bool dirExists(const std::string &directory);
-void copyFile(const std::string &src, const std::string &dst);
-void copyDir(const std::string &source, const std::string &destination);
+void copyCynaraFile(const std::string &src, const std::string &dst);
+void copyCynaraFiles(const std::string &source, const std::string &destination);
void makeDir(const std::string &directory);
-void clear(const std::string &dir);
+void removeDirFiles(const std::string &dir);
void removeDirIfExists(const std::string &dir);
} // namespace FileOperations