userver: fs::blocking::TempFile Class Reference
Loading...
Searching...
No Matches
fs::blocking::TempFile Class Referencefinal

#include <userver/fs/blocking/temp_file.hpp>

Detailed Description

A unique temporary file. The file is deleted when the TempFile object is destroyed.

Note
The file has permissions=0600. Any newly created parent directories have permissions=0700.
The newly created file is immediately opened with read-write permissions. The file descriptor can be accessed using File.

Definition at line 21 of file temp_file.hpp.

Public Member Functions

 TempFile (TempFile &&other) noexcept
 
TempFileoperator= (TempFile &&other) noexcept
 
const std::string & GetPath () const
 The file path.
 
void Remove () &&
 Remove the file early.
 

Static Public Member Functions

static TempFile Create ()
 Create the file at the default path for temporary files.
 
static TempFile Create (std::string_view parent_path, std::string_view name_prefix)
 Create the file at the specified path.
 
static TempFile Adopt (std::string path)
 Take ownership of an existing file.
 

Member Function Documentation

◆ Create() [1/2]

static TempFile fs::blocking::TempFile::Create ( )
static

Create the file at the default path for temporary files.

Exceptions
std::runtime_error

◆ Create() [2/2]

static TempFile fs::blocking::TempFile::Create ( std::string_view parent_path,
std::string_view name_prefix )
static

Create the file at the specified path.

Parameters
parent_pathThe directory where the temporary file will be created
name_prefixFile name prefix, a random string will be added after the prefix
Exceptions
std::runtime_error

◆ Remove()

void fs::blocking::TempFile::Remove ( ) &&

Remove the file early.

Exceptions
std::runtime_error

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