TPIE

2362a60
tpie::tempname Class Reference

Static methods for generating temporary file names and finding temporary file directories. More...

#include <tpie/tempname.h>

Static Public Member Functions

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. More...
 
static std::string tpie_dir_name (const std::string &post_base="", const std::string &dir="")
 Generate path for a new temporary directory. More...
 
static std::string get_system_path ()
 Get the default path for temporary files on the system. More...
 
static bool try_directory (const std::string &path, const std::string &subdir="")
 Tests whether a temporary path is usable for tpie. More...
 
static void set_default_path (const std::string &path, const std::string &subdir="")
 Sets the default temporary path. More...
 
static void set_default_base_name (const std::string &name)
 Set default base name for temporary files. More...
 
static void set_default_extension (const std::string &ext)
 Set default extension for temporary files. More...
 
static const std::string & get_default_path ()
 Get default path for directory containing temporary files if one is set using set_default_path. More...
 
static const std::string & get_default_base_name ()
 Get default base name for temporary files if one is set using set_default_base_name. More...
 
static const std::string & get_default_extension ()
 Get default extension for temporary files if one is set using set_default_extension. More...
 
static std::string get_actual_path ()
 Return The actual path used for temporary files taking environment variables into account. More...
 

Detailed Description

Static methods for generating temporary file names and finding temporary file directories.

Definition at line 50 of file tempname.h.

Member Function Documentation

static std::string tpie::tempname::get_actual_path ( )
static

Return The actual path used for temporary files taking environment variables into account.

The path is the found by querying the following in order:

TPIE2 TPIE global temp dir as set using set_default_path from source:/trunk/tpie/tempname.h TPIE1 TPIE environment varables (currently AMI_SINGLE_DEVICE) OS2 OS specific environment variables (like TMPDIR/TMP) OS1 OS specific standard path (/tmp or /var/tmp on unices and some windows thing for windows)

Returns
A string containing the path.
static const std::string& tpie::tempname::get_default_base_name ( )
static

Get default base name for temporary files if one is set using set_default_base_name.

See also
set_default_base_name
static const std::string& tpie::tempname::get_default_extension ( )
static

Get default extension for temporary files if one is set using set_default_extension.

See also
set_default_extension
static const std::string& tpie::tempname::get_default_path ( )
static

Get default path for directory containing temporary files if one is set using set_default_path.

See also
get_actual_path
static std::string tpie::tempname::get_system_path ( )
static

Get the default path for temporary files on the system.

static void tpie::tempname::set_default_base_name ( const std::string &  name)
static

Set default base name for temporary files.

See also
tpie_name
static void tpie::tempname::set_default_extension ( const std::string &  ext)
static

Set default extension for temporary files.

See also
tpie_name
static void tpie::tempname::set_default_path ( const std::string &  path,
const std::string &  subdir = "" 
)
static

Sets the default temporary path.

Parameters
pathThe default path to use; this path must exist in the system.
subdirSubdirectory of the temporary path, will be created if it does not exist.
static std::string tpie::tempname::tpie_dir_name ( const std::string &  post_base = "",
const std::string &  dir = "" 
)
static

Generate path for a new temporary directory.

The rules for the generated path are the same as tpie_name, except no file extension is added.

static std::string tpie::tempname::tpie_name ( const std::string &  post_base = "",
const std::string &  dir = "",
const std::string &  ext = "" 
)
static

Generate path for a new temporary file.

The temporary file name consists of a base name, set using set_default_base_name and defaulting to "TPIE"; an optional post base name, given as parameter to tpie_name; and a random string of characters. The parts are joined with underscores, and a file extension, either given as parameter to tpie_name or to set_default_extension. If neither is used, "tpie" will be used as the extension.

This file name is suffixed a temporary directory passed as a parameter. If no temporary directory is passed, the directory reported by get_actual_path is used instead.

The path returned does not already exist on the filesystem.

static bool tpie::tempname::try_directory ( const std::string &  path,
const std::string &  subdir = "" 
)
static

Tests whether a temporary path is usable for tpie.

Parameters
pathThe path to test
subdirSubdirectory of the temporary path, will be created if it does not exist.

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