From 9ea5eceb0ede582dc94125b2e8712dc0e58b88ce Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 23 Aug 2017 14:56:52 -0600 Subject: [PATCH] ircd::fs: Add function to read file from local filesystem. --- include/ircd/fs.h | 2 ++ ircd/fs.cc | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/ircd/fs.h b/include/ircd/fs.h index 5075e1f9b..a1fdde8f1 100644 --- a/include/ircd/fs.h +++ b/include/ircd/fs.h @@ -94,5 +94,7 @@ std::vector ls_recursive(const std::string &path); std::string cwd(); void chdir(const std::string &path); +std::string read(const std::string &name); + } // namespace fs } // namespace ircd diff --git a/ircd/fs.cc b/ircd/fs.cc index df4808f2a..8b12ed869 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -60,6 +60,15 @@ std::array()> paths } // namespace fs } // namespace ircd +std::string +ircd::fs::read(const std::string &path) +{ + std::ifstream file{path}; + std::noskipws(file); + std::istream_iterator b{file}; + std::istream_iterator e{}; + return std::string{b, e}; +} void ircd::fs::chdir(const std::string &path)