coral A C++ library for distributed co-simulation
coral::util::TempDir Class Reference

An RAII object that creates a unique directory on construction and recursively deletes it again on destruction. More...

#include "coral/util/filesystem.hpp"

## Public Member Functions

TempDir (const boost::filesystem::path &parent=boost::filesystem::path())
Creates a new temporary directory. More...

TempDir (TempDir &&other) CORAL_NOEXCEPT
Move constructor. More...

TempDiroperator= (TempDir &&) CORAL_NOEXCEPT
Move assignment operator. See TempDir(TempDir&&) for semantics.

~TempDir () CORAL_NOEXCEPT
Destructor. Recursively deletes the directory.

const boost::filesystem::path & Path () const
Returns the path to the directory.

## Detailed Description

An RAII object that creates a unique directory on construction and recursively deletes it again on destruction.

## Constructor & Destructor Documentation

 coral::util::TempDir::TempDir ( const boost::filesystem::path & parent = boost::filesystem::path() )
explicit

Creates a new temporary directory.

The name of the new directory will be randomly generated, and there are three options of where it will be created, depending on the value of parent. In the following, temp refers to a directory suitable for temporary files under the conventions of the operating system (e.g. /tmp under UNIX-like systems), and name refers to the randomly generated name mentioned above.

• If parent is empty: temp/name
• If parent is relative: temp/parent/name
• If parent is absolute: parent/name
 coral::util::TempDir::TempDir ( TempDir && other )

Move constructor.

Ownership of the directory is transferred from other to this. Afterwards, other no longer refers to any directory, meaning that other.Path() will return an empty path, and its destructor will not perform any filesystem operations.

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