From bf445492db687192992393b11d5999f9dd188a8f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 24 Apr 2018 18:34:46 -0700 Subject: [PATCH] ircd::fs: Use const_buffer rather than string_view in various returns. --- include/ircd/fs/read.h | 2 +- include/ircd/fs/write.h | 10 +++++----- ircd/aio.cc | 8 ++++---- ircd/aio.h | 4 ++-- ircd/fs.cc | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/ircd/fs/read.h b/include/ircd/fs/read.h index 6e8275ca6..5dbbfcc77 100644 --- a/include/ircd/fs/read.h +++ b/include/ircd/fs/read.h @@ -16,7 +16,7 @@ namespace ircd::fs struct read_opts extern const read_opts_default; // Yields ircd::ctx for read into buffer; returns view of read portion. - string_view read(const string_view &path, const mutable_buffer &, const read_opts & = read_opts_default); + const_buffer read(const string_view &path, const mutable_buffer &, const read_opts & = read_opts_default); // Yields ircd::ctx for read into allocated string; returns that string std::string read(const string_view &path, const read_opts & = read_opts_default); diff --git a/include/ircd/fs/write.h b/include/ircd/fs/write.h index e2913986e..717166842 100644 --- a/include/ircd/fs/write.h +++ b/include/ircd/fs/write.h @@ -16,13 +16,13 @@ namespace ircd::fs struct write_opts extern const write_opts_default; // Yields ircd::ctx for write from buffer; returns view of written portion - string_view write(const string_view &path, const const_buffer &, const write_opts & = write_opts_default); + const_buffer write(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 - string_view overwrite(const string_view &path, 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); // Yields ircd::ctx to append to file from buffer; returns view of written portion - string_view 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); } /// Options for a write operation @@ -52,7 +52,7 @@ ircd::fs::write_opts::write_opts(const off_t &offset) :offset{offset} {} -inline ircd::string_view +inline ircd::const_buffer ircd::fs::overwrite(const string_view &path, const const_buffer &buf, const write_opts &opts_) @@ -62,7 +62,7 @@ ircd::fs::overwrite(const string_view &path, return write(path, buf, opts); } -inline ircd::string_view +inline ircd::const_buffer ircd::fs::append(const string_view &path, const const_buffer &buf, const write_opts &opts_) diff --git a/ircd/aio.cc b/ircd/aio.cc index 53ecb8b0f..c4a0600a2 100644 --- a/ircd/aio.cc +++ b/ircd/aio.cc @@ -324,7 +324,7 @@ ircd::fs::read__aio(const string_view &path, }); } -ircd::string_view +ircd::const_buffer ircd::fs::read__aio(const string_view &path, const mutable_buffer &buf, const read_opts &opts) @@ -357,7 +357,7 @@ ircd::fs::read__aio(const string_view &path, request() }; - const string_view view + const const_buffer view { reinterpret_cast(data(buf)), bytes }; @@ -391,7 +391,7 @@ ircd::fs::aio::request::write::write(const int &fd, // ircd::fs interface // -ircd::string_view +ircd::const_buffer ircd::fs::write__aio(const string_view &path, const const_buffer &buf, const write_opts &opts) @@ -432,7 +432,7 @@ ircd::fs::write__aio(const string_view &path, request() }; - const string_view view + const const_buffer view { data(buf), bytes }; diff --git a/ircd/aio.h b/ircd/aio.h index 294ecdc24..37626f3c0 100644 --- a/ircd/aio.h +++ b/ircd/aio.h @@ -74,8 +74,8 @@ struct ircd::fs::aio::request namespace ircd::fs { - string_view write__aio(const string_view &path, const const_buffer &, const write_opts &); - string_view read__aio(const string_view &path, const mutable_buffer &, const read_opts &); + const_buffer write__aio(const string_view &path, const const_buffer &, const write_opts &); + const_buffer read__aio(const string_view &path, const mutable_buffer &, const read_opts &); std::string read__aio(const string_view &path, const read_opts &); } diff --git a/ircd/fs.cc b/ircd/fs.cc index bfa497820..cdfd7e9aa 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -116,7 +116,7 @@ ircd::fs::stdin::readline(const mutable_buffer &buf) namespace ircd::fs { - string_view read__std(const string_view &path, const mutable_buffer &, const read_opts &); + const_buffer read__std(const string_view &path, const mutable_buffer &, const read_opts &); std::string read__std(const string_view &path, const read_opts &); } @@ -148,7 +148,7 @@ catch(const std::exception &e) }; } -ircd::string_view +ircd::const_buffer ircd::fs::read(const string_view &path, const mutable_buffer &buf, const read_opts &opts) @@ -184,7 +184,7 @@ ircd::fs::read__std(const string_view &path, return std::string{b, e}; } -ircd::string_view +ircd::const_buffer ircd::fs::read__std(const string_view &path, const mutable_buffer &buf, const read_opts &opts) @@ -206,14 +206,14 @@ ircd::fs::read__std(const string_view &path, namespace ircd::fs { - string_view write__std(const string_view &path, const const_buffer &, const write_opts &); + const_buffer write__std(const string_view &path, const const_buffer &, const write_opts &); } ircd::fs::write_opts const ircd::fs::write_opts_default {}; -ircd::string_view +ircd::const_buffer ircd::fs::write(const string_view &path, const const_buffer &buf, const write_opts &opts) @@ -234,7 +234,7 @@ catch(const std::exception &e) }; } -ircd::string_view +ircd::const_buffer ircd::fs::write__std(const string_view &path, const const_buffer &buf, const write_opts &opts)