|
@@ -0,0 +1,50 @@
|
|
|
+#include <stdio.h>
|
|
|
+#ifdef _WIN32
|
|
|
+#include <io.h>
|
|
|
+#else
|
|
|
+#include <sys/stat.h>
|
|
|
+#include <unistd.h>
|
|
|
+#include <sys/types.h>
|
|
|
+#include <string.h>
|
|
|
+#endif
|
|
|
+
|
|
|
+#define STAT(path, buf) platform_stat(path, buf)
|
|
|
+static int platform_stat(const char *path, struct stat *buf)
|
|
|
+{
|
|
|
+ #ifdef _WIN32
|
|
|
+ return _stat(path, buf);
|
|
|
+ #else
|
|
|
+ return stat(path, buf);
|
|
|
+ #endif
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#define FOPEN(path, method) platform_fopen(path, method)
|
|
|
+static FILE* platform_fopen(const char* path, const char* method)
|
|
|
+{
|
|
|
+ #ifdef _WIN32
|
|
|
+ #else
|
|
|
+
|
|
|
+ FILE* fp = fopen(path, method);
|
|
|
+ #endif
|
|
|
+
|
|
|
+ return fp;
|
|
|
+}
|
|
|
+
|
|
|
+#define ACCESS(path, mode) platform_access(path, mode)
|
|
|
+static int platform_access(const char* path, int mode)
|
|
|
+{
|
|
|
+ #ifdef _WIN32
|
|
|
+ #else
|
|
|
+ return access(path, mode);
|
|
|
+ #endif
|
|
|
+}
|
|
|
+
|
|
|
+#define STRCPY(dst, src) platform_strcpy(dst, src)
|
|
|
+static char *platform_strcpy(char* dst, char* src)
|
|
|
+{
|
|
|
+ #ifdef _WIN32
|
|
|
+ #else
|
|
|
+ return strcpy(dst, src);
|
|
|
+ #endif
|
|
|
+}
|