Adapts fopen/fopen_s to WIN32/GCC compile

This commit is contained in:
Linus Probert 2019-03-11 08:02:31 +01:00
parent af930f6b23
commit 40a20e936c
1 changed files with 9 additions and 6 deletions

View File

@ -57,9 +57,9 @@
#include "time.h" #include "time.h"
#include "sprite_util.h" #include "sprite_util.h"
#include "event.h" #include "event.h"
#include "checksum.h"
#ifdef STEAM_BUILD #ifdef STEAM_BUILD
#include "checksum.h"
#include "steam/steamworks_api_wrapper.h" #include "steam/steamworks_api_wrapper.h"
#endif // STEAM_BUILD #endif // STEAM_BUILD
@ -1362,6 +1362,7 @@ void close(void)
SDL_Quit(); SDL_Quit();
} }
#ifdef STEAM_BUILD
static void static void
validate_lib_checksum(void) validate_lib_checksum(void)
{ {
@ -1369,16 +1370,17 @@ validate_lib_checksum(void)
#ifdef WIN32 #ifdef WIN32
const char *file = "./steam_api.dll"; const char *file = "./steam_api.dll";
unsigned int expected = DLL_LIBSTEAM_CHECKSUM; unsigned int expected = DLL_LIBSTEAM_CHECKSUM;
#else fopen_s(&fp, file, "rb");
#else // WIN32
const char *file = "./libsteam_api.so"; const char *file = "./libsteam_api.so";
unsigned int expected = SO_LIBSTEAM_CHECKSUM; unsigned int expected = SO_LIBSTEAM_CHECKSUM;
#endif fp = fopen(file, "rb");
#endif // WIN32
fopen_s(&fp, file, "rb"); if (!fp) {
if (!fp)
{
fatal("Unable to open %s for reading\n", file); fatal("Unable to open %s for reading\n", file);
} }
unsigned calculated = checksum_fp(fp); unsigned calculated = checksum_fp(fp);
fclose(fp); fclose(fp);
@ -1388,6 +1390,7 @@ validate_lib_checksum(void)
info("Checksum validated: %#x", calculated); info("Checksum validated: %#x", calculated);
} }
} }
#endif // STEAM_BUILD
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {