0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

ircd::fs: Deinline and improve overwrite() suite.

This commit is contained in:
Jason Volk 2018-08-23 21:23:42 -07:00
parent ec0670262e
commit 888862ec56
2 changed files with 23 additions and 15 deletions

View file

@ -24,7 +24,8 @@ namespace ircd::fs
const_buffer append(const string_view &path, const const_buffer &, const write_opts & = write_opts_default); const_buffer append(const string_view &path, const const_buffer &, const write_opts & = write_opts_default);
// Yields ircd::ctx to overwrite (trunc) file from buffer; returns view of written portion // Yields ircd::ctx to overwrite (trunc) file from buffer; returns view of written portion
const_buffer overwrite(const string_view &path, const const_buffer &, const write_opts & = write_opts_default); const_buffer overwrite(const fd &, const const_buffer & = {}, const write_opts & = write_opts_default);
const_buffer overwrite(const string_view &path, const const_buffer & = {}, const write_opts & = write_opts_default);
} }
/// Options for a write operation /// Options for a write operation
@ -44,20 +45,6 @@ inline
ircd::fs::write_opts::write_opts(const off_t &offset) ircd::fs::write_opts::write_opts(const off_t &offset)
:offset{offset} :offset{offset}
{} {}
inline ircd::const_buffer
ircd::fs::overwrite(const string_view &path,
const const_buffer &buf,
const write_opts &opts)
{
const fd fd
{
path, std::ios::out | std::ios::trunc
};
return write(fd, buf, opts);
}
inline ircd::const_buffer inline ircd::const_buffer
ircd::fs::append(const string_view &path, ircd::fs::append(const string_view &path,
const const_buffer &buf, const const_buffer &buf,

View file

@ -383,6 +383,27 @@ ircd::fs::write_opts
const ircd::fs::write_opts_default const ircd::fs::write_opts_default
{}; {};
ircd::const_buffer
ircd::fs::overwrite(const string_view &path,
const const_buffer &buf,
const write_opts &opts)
{
const fd fd
{
path, std::ios::out | std::ios::trunc
};
return overwrite(fd, buf, opts);
}
ircd::const_buffer
ircd::fs::overwrite(const fd &fd,
const const_buffer &buf,
const write_opts &opts)
{
return write(fd, buf, opts);
}
ircd::const_buffer ircd::const_buffer
ircd::fs::append(const fd &fd, ircd::fs::append(const fd &fd,
const const_buffer &buf, const const_buffer &buf,