Struct temporary_file

Struct Documentation

struct helpers::temporary_file

A temporary file with RAII removal

Public Functions

explicit temporary_file(fs::path filename)

Create an empty temporary file with filename as its name.

Parameters

filename – The desired filename for the file.

temporary_file(fs::path filename, const std::string_view &text)

Create a temporary file with filename as its name and text as its contents.

Parameters
  • filename – The desired filename for the file.

  • text – The text to be used for contents.

~temporary_file()

Destroy and remove a temporary file.

void write(const std::string_view &text)

Write text data to the temporary file.

Parameters

text – The text to write.

void write(const std::vector<char> &data)

Write binary data to the temporary file.

Parameters

text – The binary data to write.

fs::path filename() const

Return the filename for the temporary file.

Returns

The temporary file’s filename.

std::size_t size() const

Return the size for the temporary file.

Returns

The temporary file’s size.

Public Members

fs::path filename_
std::ofstream ofs_