20 #include <ripple/basics/FileUtilities.h>
26 boost::filesystem::path
const& sourcePath,
27 boost::optional<std::size_t> maxSize)
29 using namespace boost::filesystem;
30 using namespace boost::system::errc;
32 path fullPath{ canonical(sourcePath, ec) };
36 if (maxSize && (file_size(fullPath, ec) > *maxSize || ec))
39 ec = make_error_code(file_too_large);
43 ifstream fileStream(fullPath, std::ios::in);
47 ec = make_error_code(
static_cast<errc_t
>(errno));
54 if (fileStream.bad ())
56 ec = make_error_code(
static_cast<errc_t
>(errno));
64 boost::filesystem::path
const& destPath,
67 using namespace boost::filesystem;
68 using namespace boost::system::errc;
70 ofstream fileStream(destPath, std::ios::out | std::ios::trunc);
74 ec = make_error_code(
static_cast<errc_t
>(errno));
78 fileStream << contents;
80 if (fileStream.bad ())
82 ec = make_error_code(
static_cast<errc_t
>(errno));