Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for MSVC
 LoadDataFromFile/SaveDataToFile use fopen with unsupport file mode 'e' in MSVC.
  • Loading branch information
prodeveloper0 committed Apr 10, 2019
1 parent 332a1a9 commit e32b336
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/ccutil/genericvector.h
Expand Up @@ -374,7 +374,15 @@ using FileWriter = bool (*)(const GenericVector<char>&, const STRING&);
// returning false on error.
inline bool LoadDataFromFile(const char* filename, GenericVector<char>* data) {
bool result = false;
FILE* fp = fopen(filename, "rbe");
FILE* fp = nullptr;

// For MSVC
#if defined(_MSC_VER)
fp = fopen(filename, "rb");
#else
fp = fopen(filename, "rbe");
#endif

if (fp != nullptr) {
fseek(fp, 0, SEEK_END);
long size = ftell(fp);
Expand All @@ -400,7 +408,15 @@ inline bool LoadDataFromFile(const STRING& filename,
// returning false on error.
inline bool SaveDataToFile(const GenericVector<char>& data,
const STRING& filename) {
FILE* fp = fopen(filename.string(), "wbe");
FILE* fp = nullptr;

// For MSVC
#if defined(_MSC_VER)
fp = fopen(filename.string(), "wb");
#else
fp = fopen(filename.string(), "wbe");
#endif

if (fp == nullptr) {
return false;
}
Expand Down

0 comments on commit e32b336

Please sign in to comment.