Skip to content

Commit

Permalink
#198 on windows we need to read files in binary mode to get correct f…
Browse files Browse the repository at this point in the history
…ile size
  • Loading branch information
dibyendumajumdar committed Nov 12, 2022
1 parent 3ca3f33 commit 8afb76c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ravi_complib.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ static int load_and_compile_internal(lua_State* L, const char* s, const char* op
}

const char* read_file(const char* filename, char* error_message, size_t message_size) {
/* We need to use binary read on Windows to get file size correctly */
#ifdef _WIN32
FILE* fp = fopen(filename, "rb");
#else
FILE* fp = fopen(filename, "r");
#endif
if (fp == NULL) {
snprintf(error_message, message_size, "Failed to open file %s", filename);
return NULL;
Expand Down

0 comments on commit 8afb76c

Please sign in to comment.