mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 09:40:12 +01:00
ircd::fs: Deinline and improve overwrite() suite.
This commit is contained in:
parent
ec0670262e
commit
888862ec56
2 changed files with 23 additions and 15 deletions
|
@ -24,7 +24,8 @@ namespace ircd::fs
|
|||
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
|
||||
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
|
||||
|
@ -44,20 +45,6 @@ inline
|
|||
ircd::fs::write_opts::write_opts(const off_t &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
|
||||
ircd::fs::append(const string_view &path,
|
||||
const const_buffer &buf,
|
||||
|
|
21
ircd/fs.cc
21
ircd/fs.cc
|
@ -383,6 +383,27 @@ ircd::fs::write_opts
|
|||
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::fs::append(const fd &fd,
|
||||
const const_buffer &buf,
|
||||
|
|
Loading…
Add table
Reference in a new issue