From e487ffe1671ba807528d4039ef66f8f8f7eeb853 Mon Sep 17 00:00:00 2001 From: auth12 <67507608+auth12@users.noreply.github.com> Date: Fri, 24 Jul 2020 10:56:14 -0700 Subject: Injection process changes and server improvements. --- client/src/util/io.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'client/src/util/io.cpp') diff --git a/client/src/util/io.cpp b/client/src/util/io.cpp index 019ec3f..f6048ba 100644 --- a/client/src/util/io.cpp +++ b/client/src/util/io.cpp @@ -10,3 +10,25 @@ void io::init() { logger = std::make_shared("client", sink); } + +bool io::read_file(const std::string_view name, std::vector& out) { + std::ifstream file(name.data(), std::ios::binary); + if (!file.good()) { + io::logger->error("{} isnt valid.", name); + return false; + } + + file.unsetf(std::ios::skipws); + + file.seekg(0, std::ios::end); + const size_t size = file.tellg(); + file.seekg(0, std::ios::beg); + + out.resize(size); + + file.read(&out[0], size); + + file.close(); + + return true; +} -- cgit v1.2.3