UTILLib 2.0
Common C++ library with utilities.
|
#include <tempdir.h>
Public Member Functions | |
TempDir (const std::string &sub_dir, bool unique_dir) | |
Creates a temporary directory. | |
virtual | ~TempDir () |
The destructor removes the temporary directory. | |
const std::string & | Path () const |
Full path to the temporary directory. | |
std::string | TempFile (const std::string &stem, const std::string &extension, bool unique_file) const |
Generates a temporary and optional unique file name. |
The class creates a directory on the temporary path on the computer. The directory can be used for storing temporary files.
The directory is removed when the destructor is called.
util::log::TempDir::TempDir | ( | const std::string & | sub_dir, |
bool | unique_dir ) |
Creates a temporary directory in the default temporary directory. Normally the new directory name would be the application name. If multiple application using this function, are running on this computer, it is recommended that the unique_dir flag is set.
A unique directory is named 'sub_dir_XXXX' where X is a random hexadecimal digit. If the unique_dir flag is false, the director is named 'sub_dir'
The temporary directory and its files are removed when the destructor is called.
sub_dir | Recommended sub-directory base name. If empt a directory 'utillib' is created. |
unique_dir | If set to true, a unique directory name is created. |
|
virtual |
The destructor removes the created directory and its files
|
inlinenodiscard |
Returns full path to the temporary directory.
|
nodiscard |
Generates a temporary file name with path and extension.
stem | Base name of the file. |
extension | File extension |
unique_file | Set to true if a unique file name should be generated. |