#include "tempdir.H"
Public Member Functions | |
| Tempdir (std::string prefix, unsigned long max_tries) | |
| ~Tempdir () | |
| Destructor removes the created directory and its contents again.  | |
| std::filesystem::path | path () const | 
| Get the path of the Tempdir directory in the filesystem.  | |
A class that provides a unique temporary directory for for the lifetime of the object.
Upon destruction of Tempdir, the directory is deleted again.
| Tempdir::Tempdir | ( | std::string | prefix, | 
| unsigned long | max_tries | ||
| ) | 
Constructor for Tempdir
The created temporary directory will be put into std::filesystem::temp_directory_path following the pattern: temp_directory_path()/<prefix><hash> Where hash is a 64 bit random number in hex form obtained in at most max_tries attempts to find a name string for a path that does not yet exist.
| prefix | [in] some string to prefix the directory name with. | 
| max_tries | [in] number of tries to guess a unique random name for the directory. | 
Implementation of finding a unique temporary directory
Requires C++17, see: https://cirosantilli.com/linux-kernel-module-cheat#cpp