|
@@ -1,19 +1,25 @@
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
#include <io.h>
|
|
#include <io.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <sys/types.h>
|
|
#else
|
|
#else
|
|
-#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/types.h>
|
|
-#include <string.h>
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#define STAT(path, buf) platform_stat(path, buf)
|
|
#define STAT(path, buf) platform_stat(path, buf)
|
|
-static int platform_stat(const char *path, struct stat *buf)
|
|
|
|
|
|
+static int platform_stat(const char *path, void *buf)
|
|
{
|
|
{
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
- return _stat(path, buf);
|
|
|
|
|
|
+ struct _stat *bufstat = (struct _stat*) buf;
|
|
|
|
+ return _stat(path, bufstat);
|
|
#else
|
|
#else
|
|
|
|
+ struct stat *bufstat = (struct stat*) buf;
|
|
return stat(path, buf);
|
|
return stat(path, buf);
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
@@ -23,8 +29,13 @@ static int platform_stat(const char *path, struct stat *buf)
|
|
static FILE* platform_fopen(const char* path, const char* method)
|
|
static FILE* platform_fopen(const char* path, const char* method)
|
|
{
|
|
{
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
|
|
+ FILE* fp;
|
|
|
|
+ errno_t err;
|
|
|
|
+ err = fopen_s(&fp, path, method);
|
|
|
|
+ if (err != 0) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
#else
|
|
#else
|
|
-
|
|
|
|
FILE* fp = fopen(path, method);
|
|
FILE* fp = fopen(path, method);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -35,6 +46,7 @@ static FILE* platform_fopen(const char* path, const char* method)
|
|
static int platform_access(const char* path, int mode)
|
|
static int platform_access(const char* path, int mode)
|
|
{
|
|
{
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
|
|
+ return _access(path, mode);
|
|
#else
|
|
#else
|
|
return access(path, mode);
|
|
return access(path, mode);
|
|
#endif
|
|
#endif
|
|
@@ -44,6 +56,8 @@ static int platform_access(const char* path, int mode)
|
|
static char *platform_strcpy(char* dst, char* src)
|
|
static char *platform_strcpy(char* dst, char* src)
|
|
{
|
|
{
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
|
|
+ strcpy_s(dst, 1024, src);
|
|
|
|
+ return NULL;
|
|
#else
|
|
#else
|
|
return strcpy(dst, src);
|
|
return strcpy(dst, src);
|
|
#endif
|
|
#endif
|