Electroneum
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
tools::private_file Class Reference

A file restricted to process owner AND process. Deletes file on destruction. More...

#include <util.h>

Public Member Functions

 private_file () noexcept
 handle() == nullptr && filename.empty(). More...
 
 private_file (private_file &&)=default
 
private_fileoperator= (private_file &&)=default
 
 ~private_file () noexcept
 Deletes filename() and closes handle(). More...
 
std::FILE * handle () const noexcept
 
const std::string & filename () const noexcept
 

Static Public Member Functions

static private_file create (std::string filename)
 

Private Member Functions

 private_file (std::FILE *handle, std::string &&filename) noexcept
 

Private Attributes

std::unique_ptr< std::FILE, close_filem_handle
 
std::string m_filename
 

Detailed Description

A file restricted to process owner AND process. Deletes file on destruction.

Constructor & Destructor Documentation

◆ private_file() [1/3]

tools::private_file::private_file ( std::FILE *  handle,
std::string &&  filename 
)
privatenoexcept

◆ private_file() [2/3]

tools::private_file::private_file ( )
noexcept

handle() == nullptr && filename.empty().

◆ private_file() [3/3]

tools::private_file::private_file ( private_file &&  )
default

◆ ~private_file()

tools::private_file::~private_file ( )
noexcept

Deletes filename() and closes handle().

Member Function Documentation

◆ create()

private_file tools::private_file::create ( std::string  filename)
static
Returns
File only readable by owner and only used by this process OR private_file{} on error.

◆ filename()

const std::string& tools::private_file::filename ( ) const
inlinenoexcept

◆ handle()

std::FILE* tools::private_file::handle ( ) const
inlinenoexcept

◆ operator=()

private_file& tools::private_file::operator= ( private_file &&  )
default

Member Data Documentation

◆ m_filename

std::string tools::private_file::m_filename
private

◆ m_handle

std::unique_ptr<std::FILE, close_file> tools::private_file::m_handle
private

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