diff options
author | wm4 <wm4@nowhere> | 2014-10-17 21:46:08 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-10-17 22:15:19 +0200 |
commit | 201a65635055cb5a2987dc23819ba0fcb18e4e14 (patch) | |
tree | c6ac3b5e4392579ff0f6ed22efb9cd780984bc1c /osdep/io.c | |
parent | a7eb363ac1acb5566ce1af923d07c658361d5ad4 (diff) | |
download | mpv-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.c')
-rw-r--r-- | osdep/io.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/osdep/io.c b/osdep/io.c index b93618400c..a78dd78c2c 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -132,11 +132,36 @@ void mp_get_converted_argv(int *argc, char ***argv) *argv = win32_argv_utf8; } -int mp_stat(const char *path, struct stat *buf) +static void copy_stat(struct mp_stat *dst, struct _stat64 *src) { + dst->st_dev = src->st_dev; + dst->st_ino = src->st_ino; + dst->st_mode = src->st_mode; + dst->st_nlink = src->st_nlink; + dst->st_uid = src->st_uid; + dst->st_gid = src->st_gid; + dst->st_rdev = src->st_rdev; + dst->st_size = src->st_size; + dst->st_atime = src->st_atime; + dst->st_mtime = src->st_mtime; + dst->st_ctime = src->st_ctime; +} + +int mp_stat(const char *path, struct mp_stat *buf) +{ + struct _stat64 buf_; wchar_t *wpath = mp_from_utf8(NULL, path); - int res = _wstati64(wpath, buf); + int res = _wstat64(wpath, &buf_); talloc_free(wpath); + copy_stat(buf, &buf_); + return res; +} + +int mp_fstat(int fd, struct mp_stat *buf) +{ + struct _stat64 buf_; + int res = _fstat64(fd, &buf_); + copy_stat(buf, &buf_); return res; } |