12#ifndef INCLUDE_ARK_FILES_HPP
13#define INCLUDE_ARK_FILES_HPP
33 return std::filesystem::exists(std::filesystem::path(name));
35 catch (
const std::filesystem::filesystem_error&)
48 inline std::string
readFile(
const std::string& name)
50 std::ifstream f(name);
53 (std::istreambuf_iterator<char>(f)),
54 std::istreambuf_iterator<char>()
61 std::ifstream ifs(name, std::ios::binary | std::ios::ate);
63 return std::vector<uint8_t> {};
65 const std::size_t pos = ifs.tellg();
67 std::vector<char> temp(pos);
68 ifs.seekg(0, std::ios::beg);
69 ifs.read(&temp[0], pos);
72 auto bytecode = std::vector<uint8_t>(pos);
74 for (std::size_t i = 0; i < pos; ++i)
75 bytecode[i] =
static_cast<uint8_t
>(temp[i]);
87 return relative(std::filesystem::path(path)).generic_string();
std::string readFile(const std::string &name)
Helper to read a file.
bool fileExists(const std::string &name) noexcept
Checks if a file exists.
std::string canonicalRelPath(const std::string &path)
Get the canonical relative path from a path.
std::vector< uint8_t > readFileAsBytes(const std::string &name)