From e82be612a1a96818f6ed46398a89082f301add45 Mon Sep 17 00:00:00 2001 From: haphzd Date: Wed, 8 Jun 2016 22:37:00 +0400 Subject: [PATCH] Open binary files in binary mode --- rwengine/src/engine/GameData.cpp | 2 +- rwengine/src/engine/SaveGame.cpp | 4 ++-- rwlib/source/platform/FileIndex.cpp | 2 +- scripttool/main.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rwengine/src/engine/GameData.cpp b/rwengine/src/engine/GameData.cpp index c2fe7480..f2499b6c 100644 --- a/rwengine/src/engine/GameData.cpp +++ b/rwengine/src/engine/GameData.cpp @@ -371,7 +371,7 @@ void GameData::loadGXT(const std::string &name) void GameData::loadWaterpro(const std::string& path) { - std::ifstream ifstr(path.c_str()); + std::ifstream ifstr(path.c_str(), std::ios_base::binary); if(ifstr.is_open()) { uint32_t numlevels; diff --git a/rwengine/src/engine/SaveGame.cpp b/rwengine/src/engine/SaveGame.cpp index 2c074966..83c4f43d 100644 --- a/rwengine/src/engine/SaveGame.cpp +++ b/rwengine/src/engine/SaveGame.cpp @@ -510,7 +510,7 @@ template bool readBlock(std::FILE* str, T& out) { bool SaveGame::loadGame(GameState& state, const std::string& file) { - std::FILE* loadFile = std::fopen(file.c_str(), "r"); + std::FILE* loadFile = std::fopen(file.c_str(), "rb"); if (loadFile == nullptr) { std::cerr << "Failed to open save file" << std::endl; return false; @@ -1202,7 +1202,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) #include bool SaveGame::getSaveInfo(const std::string& file, BasicState *basicState) { - std::FILE* loadFile = std::fopen(file.c_str(), "r"); + std::FILE* loadFile = std::fopen(file.c_str(), "rb"); SaveGameInfo info; info.savePath = file; diff --git a/rwlib/source/platform/FileIndex.cpp b/rwlib/source/platform/FileIndex.cpp index c9219667..103fa36e 100644 --- a/rwlib/source/platform/FileIndex.cpp +++ b/rwlib/source/platform/FileIndex.cpp @@ -155,7 +155,7 @@ FileHandle FileIndex::openFile(const std::string& filename) } else { - std::ifstream dfile(fsName.c_str()); + std::ifstream dfile(fsName.c_str(), std::ios_base::binary); if ( ! dfile.is_open()) { throw std::runtime_error("Unable to open file: " + fsName); } diff --git a/scripttool/main.cpp b/scripttool/main.cpp index 2d792b6a..08753768 100644 --- a/scripttool/main.cpp +++ b/scripttool/main.cpp @@ -106,7 +106,7 @@ void dumpOpcodes(SCMFile* scm, SCMOpcodes* codes, unsigned int offset, unsigned void disassemble(const std::string& scmname) { - std::ifstream scmfile(scmname.c_str()); + std::ifstream scmfile(scmname.c_str(), std::ios_base::binary); if( !scmfile.is_open() ) { std::cerr << "Failed to open " << scmname << std::endl;