Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Functions
readwritefile.cpp File Reference
#include <util/fs.h>
#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=std::numeric_limits< size_t >::max())
 Read full contents of a file and return them in a std::string.
 
bool WriteBinaryFile (const fs::path &filename, const std::string &data)
 Write contents of std::string to a file.
 

Function Documentation

◆ ReadBinaryFile()

std::pair< bool, std::string > ReadBinaryFile ( const fs::path filename,
size_t  maxsize = std::numeric_limitssize_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 14 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 36 of file readwritefile.cpp.

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