coral
A C++ library for distributed co-simulation
filesystem.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_UTIL_FILESYSTEM_HPP
11 #define CORAL_UTIL_FILESYSTEM_HPP
12 
13 #include <boost/filesystem.hpp>
14 #include <coral/config.h>
15 
16 
17 namespace coral
18 {
19 namespace util
20 {
21 
22 
27 class TempDir
28 {
29 public:
44  explicit TempDir(
45  const boost::filesystem::path& parent = boost::filesystem::path());
46 
47  TempDir(const TempDir&) = delete;
48  TempDir& operator=(const TempDir&) = delete;
49 
58  TempDir(TempDir&& other) CORAL_NOEXCEPT;
59 
61  TempDir& operator=(TempDir&&) CORAL_NOEXCEPT;
62 
64  ~TempDir() CORAL_NOEXCEPT;
65 
67  const boost::filesystem::path& Path() const;
68 
69 private:
70  void DeleteNoexcept() CORAL_NOEXCEPT;
71 
72  boost::filesystem::path m_path;
73 };
74 
75 
76 }} // namespace
77 #endif // header guard
An RAII object that creates a unique directory on construction and recursively deletes it again on de...
Definition: filesystem.hpp:27
TempDir(const boost::filesystem::path &parent=boost::filesystem::path())
Creates a new temporary directory.
~TempDir() CORAL_NOEXCEPT
Destructor. Recursively deletes the directory.
Definition: variable_io.hpp:28
const boost::filesystem::path & Path() const
Returns the path to the directory.