ReadBinaryFile

Read full contents of a file and return them in a std::string.

Synopsis

Declared in <util/readwritefile.h>

std::pair<bool, std::string>
ReadBinaryFile(
    fs::path const& filename,
    size_t maxsize = std::numeric_limits<size_t>::max());

Return Value

A pair <status, string>. If an error occurred, status is false; otherwise status is true and the file contents are returned in the string.

Parameters

NameDescription
filenamePath of the file to read.
maxsizePuts a maximum size limit on the file that is read. If the file is larger than this, truncated data (with len > maxsize) will be returned.