From 5c3f4b905a3e316b340e4e8cce9e86e547f84c97 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Mon, 17 Nov 2014 07:18:39 +0100 Subject: [PATCH] Use fopen with binary mode everywhere (for Windows compat) --- binding-mruby/binding-mruby.cpp | 4 ++-- src/keybindings.cpp | 4 ++-- src/sharedstate.cpp | 2 +- src/util.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/binding-mruby/binding-mruby.cpp b/binding-mruby/binding-mruby.cpp index dc1eb40..f895de3 100644 --- a/binding-mruby/binding-mruby.cpp +++ b/binding-mruby/binding-mruby.cpp @@ -192,7 +192,7 @@ static void runCustomScript(mrb_state *mrb, mrbc_context *ctx, const char *filename) { /* Execute custom script */ - FILE *f = fopen(filename, "r"); + FILE *f = fopen(filename, "rb"); if (!f) { @@ -217,7 +217,7 @@ static void runMrbFile(mrb_state *mrb, const char *filename) { /* Execute compiled script */ - FILE *f = fopen(filename, "r"); + FILE *f = fopen(filename, "rb"); if (!f) { diff --git a/src/keybindings.cpp b/src/keybindings.cpp index a867b79..3eba75e 100644 --- a/src/keybindings.cpp +++ b/src/keybindings.cpp @@ -178,7 +178,7 @@ static bool writeBindings(const BDescVec &d, const std::string &dir, char path[1024]; buildPath(dir, rgssVersion, path, sizeof(path)); - FILE *f = fopen(path, "w"); + FILE *f = fopen(path, "wb"); if (!f) return false; @@ -263,7 +263,7 @@ static bool readBindings(BDescVec &out, const std::string &dir, char path[1024]; buildPath(dir, rgssVersion, path, sizeof(path)); - FILE *f = fopen(path, "r"); + FILE *f = fopen(path, "rb"); if (!f) return false; diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index 448a3a0..07ea572 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -125,7 +125,7 @@ struct SharedStatePrivate std::string archPath = defGameArchive(); /* Check if a game archive exists */ - FILE *tmp = fopen(archPath.c_str(), "r"); + FILE *tmp = fopen(archPath.c_str(), "rb"); if (tmp) { fileSystem.addPath(archPath.c_str()); diff --git a/src/util.h b/src/util.h index ffad798..ad9141a 100644 --- a/src/util.h +++ b/src/util.h @@ -66,7 +66,7 @@ findNextPow2(int start) inline bool readFile(const char *path, std::string &out) { - FILE *f = fopen(path, "r"); + FILE *f = fopen(path, "rb"); if (!f) return false;