mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-07-23 05:23:59 +00:00
Initial Commit
This commit is contained in:
25
PowerUtils/file.h
Normal file
25
PowerUtils/file.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
inline static std::vector<uint8_t> LoadFile(const char* path)
|
||||
{
|
||||
std::vector<uint8_t> data{};
|
||||
auto* stream = fopen(path, "rb");
|
||||
if (stream == nullptr)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
fseek(stream, 0, SEEK_END);
|
||||
|
||||
const auto size = ftell(stream);
|
||||
|
||||
fseek(stream, 0, SEEK_SET);
|
||||
|
||||
data.resize(size);
|
||||
|
||||
fread(data.data(), 1, data.size(), stream);
|
||||
fclose(stream);
|
||||
|
||||
return data;
|
||||
}
|
Reference in New Issue
Block a user