mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-04-23 01:01:26 +00:00
29 lines
545 B
C++
29 lines
545 B
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <vector>
|
|
|
|
inline std::vector<uint8_t> LoadFile(const std::filesystem::path& path)
|
|
{
|
|
std::ifstream stream(path, std::ios::binary);
|
|
if (!stream.is_open())
|
|
{
|
|
return {};
|
|
}
|
|
|
|
stream.seekg(0, std::ios::end);
|
|
std::streampos size = stream.tellg();
|
|
stream.seekg(0, std::ios::beg);
|
|
|
|
std::vector<uint8_t> data;
|
|
data.resize(size);
|
|
stream.read((char *)(data.data()), size);
|
|
if (stream.bad())
|
|
{
|
|
return {};
|
|
}
|
|
|
|
return data;
|
|
}
|