20 #ifndef TEST_UNIT_TEST_DIRGUARD_H
21 #define TEST_UNIT_TEST_DIRGUARD_H
23 #include <ripple/basics/contract.h>
24 #include <test/jtx/TestSuite.h>
25 #include <boost/filesystem.hpp>
37 using path = boost::filesystem::path;
48 if (is_directory (toRm) && is_empty (toRm))
51 test_.log <<
"Expected " << toRm.string ()
52 <<
" to be an empty existing directory." <<
std::endl;
57 bool useCounter =
true)
61 using namespace boost::filesystem;
63 static auto subDirCounter = 0;
71 else if (is_directory (
subDir_))
77 Throw<std::runtime_error> (
78 "Cannot create directory: " +
subDir_.string ());
86 using namespace boost::filesystem;
91 test_.log <<
"Skipping rm dir: "
114 bool created_ =
false;
119 bool useCounter =
true,
bool create =
true)
120 :
DirGuard(test, subDir, useCounter)
121 , file_(file.is_absolute() ? file :
subdir() / file)
134 Throw<std::runtime_error> (
135 "Refusing to overwrite existing file: " +
144 using namespace boost::filesystem;
152 test_.log <<
"Expected " << file_.string ()
153 <<
" to be an existing file." <<
std::endl;
159 test_.log <<
"Error in ~FileGuard: "
171 return boost::filesystem::exists (file_);
179 #endif // TEST_UNIT_TEST_DIRGUARD_H