refactor: a helper for reading file into bytes
Change-Id: I6fde7ad2de464a7c4d388f7ed67ce5f0e7932bb1
diff --git a/src/utils/io.cpp b/src/utils/io.cpp
index 5de62b2..7ce41a7 100644
--- a/src/utils/io.cpp
+++ b/src/utils/io.cpp
@@ -78,6 +78,14 @@
return std::string(begin, end);
}
+/** @brief Read the entire content of `path` into a vector of bytes */
+std::vector<uint8_t> readFileToBytes(const std::filesystem::path& path)
+{
+ std::ifstream ifs(openStream(path));
+ return {std::istreambuf_iterator<char>{ifs}, {}};
+}
+
+
void writeFile(const std::string& path, const std::string_view& contents)
{
std::ofstream ofs(path);