21#ifndef LIB_TEST_TEMP_DIR_H
22#define LIB_TEST_TEMP_DIR_H
66 if (fs::exists (
loc_))
71 operator fs::path
const& ()
const
82 auto newFile =
loc_ / name;
83 if (fs::exists (newFile))
86 std::ofstream{newFile};
87 if (fs::exists (newFile) and fs::is_empty(newFile))
90 throw error::Fatal{
_Fmt{
"Failed to create unique new file %s in TempDir."} % newFile};
98 auto tmpDir = fs::temp_directory_path();
102 auto newPath = tmpDir / randName;
104 if (fs::create_directory (newPath)
105 and has_perm (newPath, fs::perms::owner_all)
106 and fs::is_empty (newPath)
110 throw error::Fatal{
_Fmt{
"Failed to create unique new TempDir after %d attempts."}
112 ,error::LUMIERA_ERROR_SAFETY_LIMIT };
121 auto newPath =
loc_ / randName;
123 if (fs::exists(newPath))
125 std::ofstream{newPath};
126 if (fs::exists(newPath) and fs::is_empty (newPath))
129 throw error::Fatal{
_Fmt{
"Failed to create unique new file at %s after %d attempts."}
131 ,error::LUMIERA_ERROR_SAFETY_LIMIT };
137 fs::remove_all (
loc_);
138 ENSURE (not fs::exists(
loc_));
uint64_t u64()
random 64bit number from full range.
A RAII style temporary directory.
fs::path establishNewFile(string prefix)
void destroyTempDirectory()
static fs::path establishNewDirectory()
fs::path makeFile(string name="")
Derived specific exceptions within Lumiera's exception hierarchy.
Types marked with this mix-in may be moved but not copied.
A front-end for using printf-style formatting.
Lumiera error handling (C++ interface).
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error.
Includes the C++ Filesystem library and provides some convenience helpers.
hard wired safety limits.
#define LUMIERA_MAX_COMPETITION
Implementation namespace for support and library code.
Random entropyGen
a global RandomSequencer seeded with real entropy
Test runner and basic definitions for tests.
string showHash(size_t hash, uint showBytes) noexcept
renders the size_t in hex, optionally only trailing bytes
bool isnil(lib::time::Duration const &dur)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Generating (pseudo) random numbers with controlled seed.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...