From a1244111a790bbc4bf91b078ebcad3f415da79da Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 3 Feb 2012 08:05:11 +0100 Subject: windows support: unicode filenames Windows uses a legacy codepage for char* / runtime functions accepting char *. Using UTF-8 as the codepage with setlocale() is explicitly forbidden. Work this around by overriding the MSVCRT functions with wrapper macros, that assume UTF-8 and use "proper" API calls like _wopen etc. to deal with unicode filenames. All code that uses standard functions that take or return filenames must now include osdep/io.h. stat() can't be overridden, because MinGW-w64 itself defines "stat" as a macro. Change code to use use mp_stat() instead. This is not perfectly clean, but still somewhat sane, and much better than littering the rest of the mplayer code with MinGW specific hacks. It's also a bit fragile, but that's actually little different from the previous situation. Also, MinGW is unlikely to ever include a nice way of dealing with this. --- mplayer.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index cdcd1d645e..f8b24a1285 100644 --- a/mplayer.c +++ b/mplayer.c @@ -27,6 +27,8 @@ #include "config.h" #include "talloc.h" +#include "osdep/io.h" + #if defined(__MINGW32__) || defined(__CYGWIN__) #include #endif @@ -875,11 +877,7 @@ static void parse_cfgfiles(struct MPContext *mpctx, m_config_t *conf) if ((conffile = get_path("")) == NULL) mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Cannot find HOME directory.\n"); else { -#ifdef __MINGW32__ - mkdir(conffile); -#else mkdir(conffile, 0777); -#endif free(conffile); if ((conffile = get_path("config")) == NULL) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "get_path(\"config\") problem\n"); @@ -968,8 +966,7 @@ static void load_per_output_config(m_config_t *conf, char *cfg, char *out) */ static int try_load_config(m_config_t *conf, const char *file) { - struct stat st; - if (stat(file, &st)) + if (!mp_path_exists(file)) return 0; mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading config '%s'\n", file); m_config_parse_config_file(conf, file); @@ -979,10 +976,10 @@ static int try_load_config(m_config_t *conf, const char *file) static void load_per_file_config(m_config_t *conf, const char * const file) { char *confpath; - char cfg[PATH_MAX]; + char cfg[MP_PATH_MAX]; const char *name; - if (strlen(file) > PATH_MAX - 14) { + if (strlen(file) > MP_PATH_MAX - 14) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, " "can not load file or directory specific config files\n"); return; @@ -991,7 +988,7 @@ static void load_per_file_config(m_config_t *conf, const char * const file) name = mp_basename(cfg); if (use_filedir_conf) { - char dircfg[PATH_MAX]; + char dircfg[MP_PATH_MAX]; strcpy(dircfg, cfg); strcpy(dircfg + (name - cfg), "mplayer.conf"); try_load_config(conf, dircfg); @@ -3974,6 +3971,10 @@ int main(int argc, char *argv[]) || !strcmp(argv[1], "--leak-report"))) talloc_enable_leak_report(); +#ifdef __MINGW32__ + mp_get_converted_argv(&argc, &argv); +#endif + char *mem_ptr; // movie info: -- cgit v1.2.3