24 #ifndef _TPIE_TEMPNAM_H
25 #define _TPIE_TEMPNAM_H
31 #include <boost/intrusive_ptr.hpp>
34 #define TMPDIR_ENV "TMPDIR"
38 #define AMI_SINGLE_DEVICE_ENV "AMI_SINGLE_DEVICE"
43 explicit tempfile_error(
const std::string & what): std::runtime_error(what) {}
69 static std::string
tpie_name(
const std::string& post_base =
"",
70 const std::string& dir =
"",
71 const std::string& ext =
"");
79 static std::string
tpie_dir_name(
const std::string& post_base =
"",
80 const std::string& dir =
"");
93 static bool try_directory(
const std::string& path,
const std::string& subdir=
"");
101 static void set_default_path(
const std::string& path,
const std::string& subdir=
"");
156 void finish_tempfile();
171 const std::string & path();
172 void update_recorded_size(stream_size_type size);
174 bool is_persistent()
const {
178 void set_persistent(
bool p) {
188 stream_size_type m_recordedSize;
189 memory_size_type m_count;
223 return m_inner->is_persistent();
231 m_inner->set_persistent(p);
245 return m_inner->path();
255 void update_recorded_size(stream_size_type size) {
256 m_inner->update_recorded_size(size);
259 boost::intrusive_ptr<bits::temp_file_inner> m_inner;
264 #endif // _TPIE_TEMPNAM_H
temp_file(const std::string &path, bool persist=false)
Create a temp_file associated with a specific file.
static std::string tpie_name(const std::string &post_base="", const std::string &dir="", const std::string &ext="")
Generate path for a new temporary file.
temp_file()
Create a temp_file associated with a temporary file.
void free()
Clears the current object reference.
This file contains a few deprecated definitions for legacy code.
void set_persistent(bool p)
Set persistence.
static std::string tpie_dir_name(const std::string &post_base="", const std::string &dir="")
Generate path for a new temporary directory.
static void set_default_base_name(const std::string &name)
Set default base name for temporary files.
void set_path(const std::string &path, bool persist=false)
Associate with a specific file.
const std::string & path()
Get the path of the associated file.
Class representing a reference to a temporary file.
Static methods for generating temporary file names and finding temporary file directories.
static const std::string & get_default_base_name()
Get default base name for temporary files if one is set using set_default_base_name.
static std::string get_system_path()
Get the default path for temporary files on the system.
static std::string get_actual_path()
Return The actual path used for temporary files taking environment variables into account...
bool is_persistent() const
static const std::string & get_default_path()
Get default path for directory containing temporary files if one is set using set_default_path.
static void set_default_extension(const std::string &ext)
Set default extension for temporary files.
static const std::string & get_default_extension()
Get default extension for temporary files if one is set using set_default_extension.
static void set_default_path(const std::string &path, const std::string &subdir="")
Sets the default temporary path.
static bool try_directory(const std::string &path, const std::string &subdir="")
Tests whether a temporary path is usable for tpie.