16 std::filesystem::path
file;
18 [[nodiscard(
"Discarding this object will immediately delete the file")]]
19 TestFile(
const std::filesystem::path& f,
bool create =
false) :
file(f) {
20 if (std::filesystem::exists(
file) && !std::filesystem::is_regular_file(f)) {
21 throw std::runtime_error(
22 "The file you supplied to TestFile exists, and is not a regular file. "
23 "This utility is only compatible with standard files. "
24 "If you were trying to take ownership of a directory, use TestDirectory instead."
32 throw std::runtime_error(
33 "Failed to open test file. Do you have dir permissions?"
42 if (std::filesystem::exists(
file)) {
43 std::filesystem::remove(
file);
Definition CaptureStream.hpp:6
Definition TestFile.hpp:15
std::filesystem::path file
Definition TestFile.hpp:16
~TestFile()
Definition TestFile.hpp:38
TestFile(const std::filesystem::path &f, bool create=false)
Definition TestFile.hpp:19
void deleteFile()
Definition TestFile.hpp:41