separate file utils
This commit is contained in:
parent
471271128f
commit
b3a4f0f51c
17
shared/futils.cpp
Normal file
17
shared/futils.cpp
Normal 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
9
shared/futils.hpp
Normal 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);
|
Loading…
Reference in New Issue
Block a user