readFile overloads
Declared in <folly/FileUtil.h>
Read entire file (if num_bytes is defaulted) or no more than num_bytes (otherwise) into container *out. The container is assumed to be contiguous, with element size equal to 1, and offer size(), reserve(), and random access (e.g. std::vector<char>, std::string, fbstring).
template<class Container>
bool
readFile(
int fd,
Container& out,
size_t num_bytes = std::numeric_limits<size_t>::max());
» more...
Same as above, but takes a std::filesystem::path instead of fd
template<class Container>
requires (std::same_as<std::filesystem::path::value_type, char>)
bool
readFile(
std::filesystem::path const& path,
Container& out,
size_t num_bytes = std::numeric_limits<size_t>::max());
» more...
Same as above, but takes in a file name instead of fd
template<class Container>
bool
readFile(
char const* file_name,
Container& out,
size_t num_bytes = std::numeric_limits<size_t>::max());
» more...
True on success, false on failure.
| Name | Description |
|---|---|
| fd | The file descriptor to read from. |
| out | The container that the file contents are read into. |
| num_bytes | Maximum number of bytes to read. |
| path | Path of the file to read. |
| file_name | Path of the file to read. |