bes  Updated for version 3.17.4
bes::TemporaryFile Class Reference

Get a new temporary file. More...

#include <BESHandlerUtil.h>

Public Member Functions

int get_fd ()
 
std::string get_name ()
 
 TemporaryFile ()
 Build a temporary file using a default template. More...
 
 TemporaryFile (const std::string &path_template)
 Get a new temporary file. More...
 
 ~TemporaryFile ()
 Free the temporary file. More...
 

Detailed Description

Get a new temporary file that will be closed and deleted when the instance is deleted (i.e., goes out of scope). The intent of this class is to build temporary files that will be closed/deleted regardless of how the caller exits - regularly or via an exception.

Definition at line 45 of file BESHandlerUtil.h.

Constructor & Destructor Documentation

◆ TemporaryFile() [1/2]

bes::TemporaryFile::TemporaryFile ( )
inline

The temporary file will be in TMP_DIR (likely /tmp) and will have a name like 'opendapXXXXXX' where the Xs are numbers or letters.

Definition at line 57 of file BESHandlerUtil.h.

◆ TemporaryFile() [2/2]

bes::TemporaryFile::TemporaryFile ( const std::string &  path_template)

Get a new temporary file using the given template. The template must give the fully qualified path for the temporary file and must end in one or more Xs (but six are usually used) with no characters following.

Note
If you pass in a bad template, behavior of this class is undefined.
Parameters
path_templateTemplate passed to mkstemp() to build the temporary file pathname.

Definition at line 52 of file BESHandlerUtil.cc.

◆ ~TemporaryFile()

bes::TemporaryFile::~TemporaryFile ( )
inline

Close the open descriptor and delete (unlink) the file name.

Definition at line 68 of file BESHandlerUtil.h.

Member Function Documentation

◆ get_fd()

int bes::TemporaryFile::get_fd ( )
inline
Returns
The temporary file's file descriptor

Definition at line 74 of file BESHandlerUtil.h.

◆ get_name()

std::string bes::TemporaryFile::get_name ( )
inline
Returns
The temporary file's name

Definition at line 77 of file BESHandlerUtil.h.


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