opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
temporary_directory.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <filesystem>
6#include <fstream>
7
8namespace osc
9{
10 // `TemporaryDirectory` securely creates and manages a temporary directory.
11 //
12 // The implementation guarantees that:
13 //
14 // - The directory is created in the operating system's temporary directory, throwing
15 // otherwise.
16 // - The name of the directory begins with `prefix`, ends with `suffix`, and the
17 // characters between those two are chosen to result in a new, unique, filename,
18 // throwing otherwise.
19 // - The directory and all of its contents are removed from the filesystem upon
20 // destruction of the `TemporaryDirectory` object.
22 public:
23 // Constructs a `TemporaryDirectory` on-disk with the given parameters.
30
31 // Returns the name of the temporary directory.
32 std::filesystem::path filename() const { return absolute_path_.filename(); }
33
34 // Returns the absolute path to the temporary directory.
35 const std::filesystem::path& absolute_path() const { return absolute_path_; }
36
37 private:
38 std::filesystem::path absolute_path_;
39 bool should_delete_ = true;
40 };
41}
Definition temporary_directory.h:21
TemporaryDirectory(const TemporaryDirectory &)=delete
TemporaryDirectory(TemporaryDirectory &&) noexcept
const std::filesystem::path & absolute_path() const
Definition temporary_directory.h:35
TemporaryDirectory(const TemporaryDirectoryParameters &={})
std::filesystem::path filename() const
Definition temporary_directory.h:32
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56
Definition temporary_directory_parameters.h:12