aboutsummaryrefslogtreecommitdiff
path: root/client/src/util/io.cpp
blob: 47d9dbea3d73e9bfb4d22dce5090e6c7ff39427e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "../include.h"
#include "io.h"

bool io::read_file(const std::string_view path, std::vector<char>& out) {
	std::ifstream file(path.data(), std::ios::binary);
	if (!file.good()) {
		log_error("{} isnt valid.", path);
		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;
}