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

#include <userver/fs/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 25 of file temp_file.hpp.

Public Member Functions

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

Static Public Member Functions

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

Member Function Documentation

◆ Create() [1/2]

static TempFile fs::TempFile::Create ( engine::TaskProcessor & fs_task_processor)
static

Create the file at the default path for temporary files.

Exceptions
std::runtime_error

◆ Create() [2/2]

static TempFile fs::TempFile::Create ( std::string_view parent_path,
std::string_view name_prefix,
engine::TaskProcessor & fs_task_processor )
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::TempFile::Remove ( ) &&

Remove the file early.

Exceptions
std::runtime_error

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