Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
TempFile Class Reference

This class creates a temporary file for the test, and removes it when the test is done. More...

#include <TempFile.hxx>

Public Member Functions

 TempFile (const TempDir &dir, const string &basename)
 Constructor.
 
const string & name () const
 
int fd ()
 
void write (const uint8_t byte)
 writes a single byte to the temporary file.
 
void rewrite (const string &s)
 writes the given data to the temporary file from offset 0.
 
void write (const string &s)
 writes the given data to the temporary file.
 

Private Attributes

string fileName_
 The full path name.
 
int fd_
 The file descriptor.
 

Detailed Description

This class creates a temporary file for the test, and removes it when the test is done.

Definition at line 84 of file TempFile.hxx.

Constructor & Destructor Documentation

◆ TempFile()

TempFile::TempFile ( const TempDir dir,
const string &  basename 
)

Constructor.

Parameters
diristhe temp directory to create the file within.
basenamewill be the prefix of the name. A unique suffix will be appended for each file.

Definition at line 69 of file TempFile.cxx.

◆ ~TempFile()

TempFile::~TempFile ( )
inline

Definition at line 92 of file TempFile.hxx.

Member Function Documentation

◆ fd()

int TempFile::fd ( )
inline
Returns
the file descriptor.

Definition at line 103 of file TempFile.hxx.

◆ name()

const string & TempFile::name ( ) const
inline
Returns
the full path name to this temporary file.

Definition at line 98 of file TempFile.hxx.

◆ rewrite()

void TempFile::rewrite ( const string &  s)

writes the given data to the temporary file from offset 0.

Parameters
sis the data to write.

Definition at line 79 of file TempFile.cxx.

◆ write() [1/2]

void TempFile::write ( const string &  s)
inline

writes the given data to the temporary file.

Parameters
sis the data to write.

Definition at line 122 of file TempFile.hxx.

◆ write() [2/2]

void TempFile::write ( const uint8_t  byte)
inline

writes a single byte to the temporary file.

Parameters
byteisthe data to write.

Definition at line 110 of file TempFile.hxx.

Member Data Documentation

◆ fd_

int TempFile::fd_
private

The file descriptor.

Definition at line 138 of file TempFile.hxx.

◆ fileName_

string TempFile::fileName_
private

The full path name.

Definition at line 136 of file TempFile.hxx.


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