diff --git a/src/util/files.cpp b/src/util/files.cpp index 38253dc..4cf87fc 100644 --- a/src/util/files.cpp +++ b/src/util/files.cpp @@ -1,4 +1,9 @@ #include "files.h" +#include + +#if defined(_MSC_VER) && defined(_WIN32) && !defined(snprintf) +#define snprintf _snprintf +#endif void ReadString(FILE *fp, std::string &buffer, int fixedLength) { @@ -6,11 +11,17 @@ void ReadString(FILE *fp, std::string &buffer, int fixedLength) if (fixedLength > 0) { + char *temp = new char[fixedLength]; + fread(temp, 1, fixedLength, fp); + for (int i = 0; i < fixedLength; ++i) { - fread(&c, 1, 1, fp); + c = temp[i]; + if (c != '\0') buffer += c; + else + break; } } else