0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::fs: Add these string_view overloads.

This is to not force string conversions in callerspace. Right now everything
gets converted to std::string internally but eventually string_view may be
preferable. Either way the overload finds the best behavior for now.
This commit is contained in:
Jason Volk 2017-12-21 13:27:22 -07:00
parent 27721860c2
commit bdf696b91f
2 changed files with 16 additions and 0 deletions

View file

@ -95,9 +95,11 @@ namespace ircd::fs
// This suite of IO functions may yield your context.
std::string read(const std::string &name);
string_view read(const std::string &name, const mutable_raw_buffer &buf);
string_view read(const string_view &name, const mutable_raw_buffer &buf);
bool write(const std::string &name, const const_raw_buffer &buf);
bool append(const std::string &name, const const_raw_buffer &buf);
bool overwrite(const std::string &name, const const_raw_buffer &buf);
bool overwrite(const string_view &name, const const_raw_buffer &buf);
struct init;
}

View file

@ -64,6 +64,13 @@ ircd::fs::write(const std::string &path,
return overwrite(path, buf);
}
bool
ircd::fs::overwrite(const string_view &path,
const const_raw_buffer &buf)
{
return overwrite(std::string{path}, buf);
}
bool
ircd::fs::overwrite(const std::string &path,
const const_raw_buffer &buf)
@ -159,6 +166,13 @@ ircd::fs::read(const std::string &path)
}
#endif
ircd::string_view
ircd::fs::read(const string_view &path,
const mutable_raw_buffer &buf)
{
return ircd::fs::read(std::string{path}, buf);
}
ircd::string_view
ircd::fs::read(const std::string &path,
const mutable_raw_buffer &buf)