summaryrefslogtreecommitdiffstats
path: root/osdep/io.h
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2014-02-13 18:18:58 +1100
committerwm4 <wm4@nowhere>2014-04-21 02:57:16 +0200
commit0cef033d4897a0b5878c4213556ba0937bd1ff91 (patch)
tree67a2edd039775840d60cd143efe48d8328d702e4 /osdep/io.h
parentff9ac834191aca42ac16007ac136ab0495e02a18 (diff)
downloadmpv-0cef033d4897a0b5878c4213556ba0937bd1ff91.tar.bz2
mpv-0cef033d4897a0b5878c4213556ba0937bd1ff91.tar.xz
glob-win: support Unicode
glob-win.c wasn't big, so it was easier to rewrite it. The new version supports Unicode, handles directories properly, sorts the output and puts all its allocations in the same talloc context to simplify the implementation of globfree. Notably, the old glob had error checking code, but didn't do anything with the errors since the error reporting code was commented out. The new glob doesn't copy this behaviour. It just treats errors as if there were no more matching files, which shouldn't matter for mpv, since it ignores glob errors too. To match the other Windows I/O helper functions, the definition is moved to osdep/io.h.
Diffstat (limited to 'osdep/io.h')
-rw-r--r--osdep/io.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/osdep/io.h b/osdep/io.h
index 4cb16677f2..53097a1b78 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -20,12 +20,17 @@
#ifndef MPLAYER_OSDEP_IO
#define MPLAYER_OSDEP_IO
+#include "config.h"
#include <stdbool.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#if HAVE_GLOB
+#include <glob.h>
+#endif
+
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -71,6 +76,18 @@ int mp_closedir(DIR *dir);
int mp_mkdir(const char *path, int mode);
char *mp_getenv(const char *name);
+typedef struct {
+ size_t gl_pathc;
+ char **gl_pathv;
+ size_t gl_offs;
+ void *ctx;
+} mp_glob_t;
+
+// glob-win.c
+int mp_glob(const char *restrict pattern, int flags,
+ int (*errfunc)(const char*, int), mp_glob_t *restrict pglob);
+void mp_globfree(mp_glob_t *pglob);
+
// NOTE: stat is not overridden with mp_stat, because MinGW-w64 defines it as
// macro.
@@ -85,6 +102,14 @@ char *mp_getenv(const char *name);
#define mkdir(...) mp_mkdir(__VA_ARGS__)
#define getenv(...) mp_getenv(__VA_ARGS__)
+#ifndef GLOB_NOMATCH
+#define GLOB_NOMATCH 3
+#endif
+
+#define glob_t mp_glob_t
+#define glob(...) mp_glob(__VA_ARGS__)
+#define globfree(...) mp_globfree(__VA_ARGS__)
+
#else /* __MINGW32__ */
#define mp_stat(...) stat(__VA_ARGS__)