folly::writeFile

writeFile overloads

Synopses

Declared in <folly/FileUtil.h>

Same as above, but takes a std::filesystem::path instead of filename

template<class Container>
requires (std::same_as<std::filesystem::path::value_type, char>)
bool
writeFile(
    Container const& data,
    std::filesystem::path const& filename,
    int flags = O_WRONLY | O_CREAT | O_TRUNC,
    mode_t mode = 0666);
» more...

Writes container to file. The container is assumed to be contiguous, with element size equal to 1, and offering STL-like methods empty(), size(), and indexed access (e.g. std::vector<char>, std::string, fbstring, StringPiece).

template<class Container>
bool
writeFile(
    Container const& data,
    char const* filename,
    int flags = O_WRONLY | O_CREAT | O_TRUNC,
    mode_t mode = 0666);
» more...

Return Value

True on success, false on failure.

Parameters

NameDescription
dataThe container whose contents are written.
filenamePath of the file to write.
flagsopen() flags controlling how the file is opened.
modePermission bits used when creating the file.