23 [[nodiscard(
"Discarding this object will immediately delete the folder")]]
25 const std::filesystem::path& p,
32 std::filesystem::create_directories(p);
36 [[nodiscard(
"Discarding this object will immediately delete the folder")]]
38 const std::filesystem::path& p,
46 std::filesystem::create_directories(p);
55 if (std::filesystem::exists(p) && (
56 !std::filesystem::is_directory(p)
57 || std::filesystem::is_symlink(p)
59 throw std::runtime_error(
60 "The path you supplied to TestDirectory exists, but is not a directory or is a symlink. "
61 "This utility is only compatible with standard directories. "
62 "If you were trying to take ownership of a file, use TestFile instead."
65 p.string().starts_with(
"/usr")
66 || p.string().starts_with(
"/bin")
67 || p.string().starts_with(
"/share")
68 || p.string().starts_with(
"/dev")
69 || p.string().starts_with(
"/etc")
70 || p.string().starts_with(
"/proc")
71 || p.string().starts_with(
"/boot")
72 || std::filesystem::weakly_canonical(p) == std::filesystem::canonical(
"/")
74 throw std::runtime_error(
85 if (std::filesystem::exists(this->folder)) {
86 std::filesystem::remove_all(this->folder);
Definition CaptureStream.hpp:6
Definition TestDirectory.hpp:19
bool dummyMode
Definition TestDirectory.hpp:21
void deleteFolder()
Definition TestDirectory.hpp:81
TestDirectory(const std::filesystem::path &p, bool create, bool dummyMode)
Definition TestDirectory.hpp:37
TestDirectory(const std::filesystem::path &p, bool create=false)
Definition TestDirectory.hpp:24
~TestDirectory()
Definition TestDirectory.hpp:50
std::filesystem::path folder
Definition TestDirectory.hpp:20
void checkCompatiblePath(const std::filesystem::path &p)
Definition TestDirectory.hpp:54