summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2014-02-13 18:50:56 +1100
committerwm4 <wm4@nowhere>2014-04-21 02:57:17 +0200
commit2a6c084e4c57f28b422a5c83e44e7297473fbb90 (patch)
treeed05ecf5c4c674b51275716bc9eddc5bfa143934 /options
parent0cef033d4897a0b5878c4213556ba0937bd1ff91 (diff)
downloadmpv-2a6c084e4c57f28b422a5c83e44e7297473fbb90.tar.bz2
mpv-2a6c084e4c57f28b422a5c83e44e7297473fbb90.tar.xz
parse_commandline: glob filenames on Windows
The Windows port uses CommandLineToArgvW, which doesn't expand wildcards in command line arguments. Use glob to expand them instead, but only for non-option arguments.
Diffstat (limited to 'options')
-rw-r--r--options/parse_commandline.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/options/parse_commandline.c b/options/parse_commandline.c
index ed567d6171..d86dde68fc 100644
--- a/options/parse_commandline.c
+++ b/options/parse_commandline.c
@@ -25,6 +25,7 @@
#include <assert.h>
#include <stdbool.h>
+#include "osdep/io.h"
#include "common/global.h"
#include "common/msg.h"
#include "common/msg_control.h"
@@ -111,6 +112,28 @@ static bool split_opt(struct parse_state *p)
return false;
}
+#ifdef __MINGW32__
+static void process_non_option(struct playlist *files, const char *arg)
+{
+ glob_t gg;
+
+ // Glob filenames on Windows (cmd.exe doesn't do this automatically)
+ if (glob(arg, 0, NULL, &gg)) {
+ playlist_add_file(files, arg);
+ } else {
+ for (int i = 0; i < gg.gl_pathc; i++)
+ playlist_add_file(files, gg.gl_pathv[i]);
+
+ globfree(&gg);
+ }
+}
+#else
+static void process_non_option(struct playlist *files, const char *arg)
+{
+ playlist_add_file(files, arg);
+}
+#endif
+
// returns M_OPT_... error code
int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
struct mpv_global *global,
@@ -234,8 +257,9 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
} else // dvd:// or dvd://x entry
playlist_add_file(files, file0);
- } else
- playlist_add_file(files, file0);
+ } else {
+ process_non_option(files, file0);
+ }
talloc_free(tmp);
// Lock stdin if it will be used as input