Skip to content

Commit e32b336

Browse files
Fix for MSVC
LoadDataFromFile/SaveDataToFile use fopen with unsupport file mode 'e' in MSVC.
1 parent 332a1a9 commit e32b336

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/ccutil/genericvector.h

+18-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,15 @@ using FileWriter = bool (*)(const GenericVector<char>&, const STRING&);
374374
// returning false on error.
375375
inline bool LoadDataFromFile(const char* filename, GenericVector<char>* data) {
376376
bool result = false;
377-
FILE* fp = fopen(filename, "rbe");
377+
FILE* fp = nullptr;
378+
379+
// For MSVC
380+
#if defined(_MSC_VER)
381+
fp = fopen(filename, "rb");
382+
#else
383+
fp = fopen(filename, "rbe");
384+
#endif
385+
378386
if (fp != nullptr) {
379387
fseek(fp, 0, SEEK_END);
380388
long size = ftell(fp);
@@ -400,7 +408,15 @@ inline bool LoadDataFromFile(const STRING& filename,
400408
// returning false on error.
401409
inline bool SaveDataToFile(const GenericVector<char>& data,
402410
const STRING& filename) {
403-
FILE* fp = fopen(filename.string(), "wbe");
411+
FILE* fp = nullptr;
412+
413+
// For MSVC
414+
#if defined(_MSC_VER)
415+
fp = fopen(filename.string(), "wb");
416+
#else
417+
fp = fopen(filename.string(), "wbe");
418+
#endif
419+
404420
if (fp == nullptr) {
405421
return false;
406422
}

0 commit comments

Comments
 (0)