24 #ifndef _TPIE_TEMPNAM_H
25 #define _TPIE_TEMPNAM_H
31 #include <boost/utility.hpp>
33 #define TMPDIR_ENV "TMPDIR"
37 #define AMI_SINGLE_DEVICE_ENV "AMI_SINGLE_DEVICE"
42 explicit tempfile_error(
const std::string & what): std::runtime_error(what) {}
68 static std::string
tpie_name(
const std::string& post_base =
"",
69 const std::string& dir =
"",
70 const std::string& ext =
"");
78 static std::string
tpie_dir_name(
const std::string& post_base =
"",
79 const std::string& dir =
"");
92 static void set_default_path(
const std::string& path,
const std::string& subdir=
"");
156 stream_size_type m_recordedSize;
178 void set_path(
const std::string &
path,
bool persist=
false);
180 void update_recorded_size(stream_size_type size) {
182 static_cast<stream_offset_type>(m_recordedSize));
202 const std::string &
path();
212 #endif // _TPIE_TEMPNAM_H
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 and generate a random temporary file name.
void free()
If not persistent, unlink the associated file.
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 the existence of 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.
void increment_temp_file_usage(stream_offset_type delta)
Increment (possibly by a negative amount) the number of bytes being used by temporary files...
~temp_file()
temp_file destructor.
static void set_default_path(const std::string &path, const std::string &subdir="")
Sets the default temporary path.