separate file utils

This commit is contained in:
17ms 2024-01-05 21:00:53 +02:00
parent 471271128f
commit b3a4f0f51c
2 changed files with 26 additions and 0 deletions

17
shared/futils.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "futils.hpp"
std::vector<BYTE> ReadFromFile(const std::string &filename)
{
std::ifstream file(filename, std::ios::binary);
std::vector<BYTE> data((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
file.close();
return data;
}
void WriteToFile(const std::string &filename, const std::vector<BYTE> &data)
{
std::ofstream file(filename, std::ios::binary);
file.write(reinterpret_cast<const char *>(data.data()), data.size());
file.close();
}

9
shared/futils.hpp Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <windows.h>
#include <string>
#include <vector>
#include <fstream>
std::vector<BYTE> ReadFromFile(const std::string &filename);
void WriteToFile(const std::string &filename, const std::vector<BYTE> &data);