wren
Vulkan-based game engine
Loading...
Searching...
No Matches
filesystem.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <filesystem>
4
#include <fstream>
5
#include <vector>
6
7
namespace
wren::utils::fs
{
8
9
auto
read_file_to_string
(
const
std::filesystem::path& path) {
10
std::ifstream file(path);
11
std::string result;
12
file >> result;
13
return
result;
14
}
15
16
auto
read_file_to_bin
(
const
std::filesystem::path& path) {
17
std::ifstream file(path, std::ios::binary);
18
19
std::streampos size;
20
file.seekg(0, std::ios::end);
21
size = file.tellg();
22
file.seekg(0, std::ios::beg);
23
24
std::vector<uint8_t> buf;
25
buf.reserve(size);
26
27
buf.insert(buf.begin(), std::istreambuf_iterator<char>(file),
28
std::istreambuf_iterator<char>());
29
30
return
buf;
31
}
32
33
}
// namespace wren::utils::fs
wren::utils::fs
Definition
filesystem.hpp:7
wren::utils::fs::read_file_to_string
auto read_file_to_string(const std::filesystem::path &path)
Definition
filesystem.hpp:9
wren::utils::fs::read_file_to_bin
auto read_file_to_bin(const std::filesystem::path &path)
Definition
filesystem.hpp:16
wren_utils
include
wren
utils
filesystem.hpp
Generated by
1.10.0