fix: write/read file as binary
This commit is contained in:
@@ -64,7 +64,7 @@ std::ostream& operator<<(std::ostream& os, const DataBuffer& buffer) {
|
|||||||
|
|
||||||
bool DataBuffer::ReadFile(const std::string& fileName) {
|
bool DataBuffer::ReadFile(const std::string& fileName) {
|
||||||
try {
|
try {
|
||||||
std::ifstream file(fileName);
|
std::ifstream file(fileName, std::istream::binary);
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << file.rdbuf();
|
ss << file.rdbuf();
|
||||||
const std::string& s = ss.str();
|
const std::string& s = ss.str();
|
||||||
@@ -79,7 +79,7 @@ bool DataBuffer::ReadFile(const std::string& fileName) {
|
|||||||
|
|
||||||
bool DataBuffer::WriteFile(const std::string& fileName) {
|
bool DataBuffer::WriteFile(const std::string& fileName) {
|
||||||
try {
|
try {
|
||||||
std::ofstream file(fileName);
|
std::ofstream file(fileName, std::ostream::binary);
|
||||||
file.write((const char*)m_Buffer.data(), m_Buffer.size());
|
file.write((const char*)m_Buffer.data(), m_Buffer.size());
|
||||||
file.flush();
|
file.flush();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user