summaryrefslogtreecommitdiffstats
path: root/osdep/io.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-17 21:46:08 +0200
committerwm4 <wm4@nowhere>2014-10-17 22:15:19 +0200
commit201a65635055cb5a2987dc23819ba0fcb18e4e14 (patch)
treec6ac3b5e4392579ff0f6ed22efb9cd780984bc1c /osdep/io.h
parenta7eb363ac1acb5566ce1af923d07c658361d5ad4 (diff)
downloadmpv-201a65635055cb5a2987dc23819ba0fcb18e4e14.tar.bz2
mpv-201a65635055cb5a2987dc23819ba0fcb18e4e14.tar.xz
win32: get rid of mp_stat in the normal source code
mp_stat() instead of stat() was used in the normal code (i.e. even on Unix), because MinGW-w64 has an unbelievable macro-mess in place, which prevents solving this elegantly. Add some dirty workarounds to hide mp_stat() from the normal code properly. This now requires replacing all functions that use the struct stat type. This includes fstat, lstat, fstatat, and possibly others. (mpv currently uses stat and fstat only.)
Diffstat (limited to 'osdep/io.h')
-rw-r--r--osdep/io.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/osdep/io.h b/osdep/io.h
index a24ad7c231..b56953aedf 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -22,6 +22,7 @@
#include "config.h"
#include <stdbool.h>
+#include <stdint.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -65,7 +66,6 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s);
void mp_get_converted_argv(int *argc, char ***argv);
-int mp_stat(const char *path, struct stat *buf);
int mp_printf(const char *format, ...);
int mp_fprintf(FILE *stream, const char *format, ...);
int mp_open(const char *filename, int oflag, ...);
@@ -79,6 +79,27 @@ FILE *mp_tmpfile(void);
char *mp_getenv(const char *name);
off_t mp_lseek(int fd, off_t offset, int whence);
+// MinGW-w64 will define "stat" to something useless. Since this affects both
+// the type (struct stat) and the stat() function, it makes us harder to
+// override these separately.
+// Corresponds to struct _stat64 (copy & pasted, but using public types).
+struct mp_stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ unsigned short st_mode;
+ short st_nlink;
+ short st_uid;
+ short st_gid;
+ dev_t st_rdev;
+ int64_t st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+};
+
+int mp_stat(const char *path, struct mp_stat *buf);
+int mp_fstat(int fd, struct mp_stat *buf);
+
typedef struct {
size_t gl_pathc;
char **gl_pathv;
@@ -113,6 +134,11 @@ void mp_globfree(mp_glob_t *pglob);
#define lseek(...) mp_lseek(__VA_ARGS__)
#endif
+#undef stat
+#define stat mp_stat
+#undef fstat
+#define fstat(...) mp_fstat(__VA_ARGS__)
+
#ifndef GLOB_NOMATCH
#define GLOB_NOMATCH 3
#endif
@@ -121,10 +147,6 @@ void mp_globfree(mp_glob_t *pglob);
#define glob(...) mp_glob(__VA_ARGS__)
#define globfree(...) mp_globfree(__VA_ARGS__)
-#else /* __MINGW32__ */
-
-#define mp_stat(...) stat(__VA_ARGS__)
-
#endif /* __MINGW32__ */
#endif