bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
bes::TempFile Class Reference

Get a new temporary file. More...

#include <TempFile.h>

Collaboration diagram for bes::TempFile:
Collaboration graph

Public Member Functions

std::string create (const std::string &dir_name="/tmp/hyrax_tmp", const std::string &path_template="opendap")
 Create a new temporary file.
 
int get_fd () const
 
std::string get_name () const
 
TempFileoperator= (const TempFile &)=delete
 
TempFileoperator= (TempFile &&)=delete
 
 TempFile (bool keep_temps)
 
 TempFile (const TempFile &)=delete
 
 TempFile (TempFile &&)=delete
 
 ~TempFile ()
 Free the temporary file.
 

Static Public Member Functions

static void sigpipe_handler (int signal)
 

Friends

class TemporaryFileTest
 

Detailed Description

Get a new temporary file.

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 43 of file TempFile.h.

Constructor & Destructor Documentation

◆ TempFile()

bes::TempFile::TempFile ( bool keep_temps)
inlineexplicit

Definition at line 70 of file TempFile.h.

◆ ~TempFile()

bes::TempFile::~TempFile ( )

Free the temporary file.

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

Definition at line 232 of file TempFile.cc.

Member Function Documentation

◆ create()

string bes::TempFile::create ( const std::string & dir_name = "/tmp/hyrax_tmp",
const std::string & temp_file_prefix = "opendap" )

Create a new temporary file.

Get a new temporary file using the given directory and temporary file prefix. If the directory does not exist it will be created.

Parameters
dir_nameThe name of the directory in which the temporary file will be created.
temp_file_prefixA prefix to be used for the temporary file.
Returns
The name of the temporary file.

Definition at line 164 of file TempFile.cc.

◆ get_fd()

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

Definition at line 84 of file TempFile.h.

◆ get_name()

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

Definition at line 87 of file TempFile.h.

◆ sigpipe_handler()

void bes::TempFile::sigpipe_handler ( int sig)
static

We need to make sure that all of the open temporary files get cleaned up if bad things happen. So far, SIGPIPE is the only bad thing we know about at least with respect to the TempFile class. FIXME This code needs to restore the existing SIGPIPE handler. See server/ServerApp.cc. jhrg 8/13/24

Definition at line 74 of file TempFile.cc.

Friends And Related Symbol Documentation

◆ TemporaryFileTest

friend class TemporaryFileTest
friend

Definition at line 45 of file TempFile.h.


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