Bitcoin Core 28.99.0
P2P Digital Currency
Functions
readwritefile.cpp File Reference
#include <util/readwritefile.h>
#include <util/fs.h>
#include <algorithm>
#include <cstdio>
#include <limits>
#include <string>
#include <utility>
Include dependency graph for readwritefile.cpp:

Go to the source code of this file.

Functions

std::pair< bool, std::string > ReadBinaryFile (const fs::path &filename, size_t maxsize)
 Read full contents of a file and return them in a std::string. More...
 
bool WriteBinaryFile (const fs::path &filename, const std::string &data)
 Write contents of std::string to a file. More...
 

Function Documentation

◆ ReadBinaryFile()

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

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

Returns a pair <status, string>. If an error occurred, status will be false, otherwise status will be true and the data will be returned in string.

Parameters
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.

Definition at line 16 of file readwritefile.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteBinaryFile()

bool WriteBinaryFile ( const fs::path filename,
const std::string &  data 
)

Write contents of std::string to a file.

Returns
true on success.

Definition at line 37 of file readwritefile.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: