Elements
6.2
A C++ base framework for the Euclid Software.
|
Go to the documentation of this file.
27 #include <boost/filesystem/fstream.hpp>
28 #include <boost/filesystem/operations.hpp>
34 using boost::filesystem::temp_directory_path;
44 : m_motif(arg_motif), m_path(temp_directory_path()), m_keep_var(keep_var) {
46 using boost::filesystem::unique_path;
49 log.error() <<
"The '" <<
m_motif <<
"' motif is not random";
54 if (pattern.empty()) {
59 m_path /= unique_path(pattern);
67 log.debug() <<
"Automatic destruction of the " <<
path() <<
" temporary path";
68 const auto file_number = boost::filesystem::remove_all(
m_path);
69 log.debug() <<
"Number of files removed: " << file_number;
71 log.info() <<
m_keep_var <<
" set: I do not remove the " <<
m_path.string() <<
" temporary path";
85 log.debug() <<
"Creation of the " <<
path() <<
" temporary directory";
87 boost::filesystem::create_directory(
path());
94 log.debug() <<
"Creation of the " <<
path() <<
" temporary file";
96 boost::filesystem::ofstream ofs(
path());
boost::filesystem::path Item
TempPath(const std::string &motif=DEFAULT_TMP_MOTIF, const std::string &keep_var=DEFAULT_TMP_KEEP_VAR)
const std::string DEFAULT_TMP_MOTIF
The default random creation motif.
provide functions to retrieve resources pointed by environment variables
TempFile(const std::string &motif=DEFAULT_TMP_MOTIF, const std::string &keep_var=DEFAULT_TMP_KEEP_VAR)
std::string motif() const
static bool hasKey(const std::string &)
const std::string m_keep_var
TempDir(const std::string &motif=DEFAULT_TMP_MOTIF, const std::string &keep_var=DEFAULT_TMP_KEEP_VAR)
static Logging getLogger(const std::string &name="")
Defines a class to handle the Environment.
Handling of temporary files, directories and environments.
Python dictionary-like Environment interface.
const std::string m_motif