b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
Tempdir Class Reference

#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.
 

Detailed Description

A class that provides a unique temporary directory for for the lifetime of the object.

Upon destruction of Tempdir, the directory is deleted again.

Constructor & Destructor Documentation

◆ Tempdir()

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.

Parameters
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


The documentation for this class was generated from the following files: