MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / read_file

Function read_file

RecompModMerger/main.cpp:7–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6template <typename T>
7bool read_file(const std::filesystem::path& p, std::vector<T>& out) {
8 static_assert(sizeof(T) == 1);
9 std::vector<T> ret{};
10
11 std::ifstream input_file{p, std::ios::binary};
12 if (!input_file.good()) {
13 return false;
14 }
15
16 input_file.seekg(0, std::ios::end);
17 ret.resize(input_file.tellg());
18 input_file.seekg(0, std::ios::beg);
19
20 input_file.read(reinterpret_cast<char*>(ret.data()), ret.size());
21
22 out = std::move(ret);
23
24 return true;
25}
26
27bool write_file(const std::filesystem::path& p, std::span<char> in) {
28 std::ofstream out{ p, std::ios::binary };

Callers 1

mainFunction · 0.70

Calls 1

goodMethod · 0.45

Tested by

no test coverage detected