summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2012-02-03 08:05:11 +0100
committerUoti Urpala <uau@mplayer2.org>2012-03-09 20:48:54 +0200
commita1244111a790bbc4bf91b078ebcad3f415da79da (patch)
treebbbb99a7364b7ee4eaa96a44930f84a88db25090 /mplayer.c
parent24be34f1e9e37111a06108c090324426aff6f1db (diff)
downloadmpv-a1244111a790bbc4bf91b078ebcad3f415da79da.tar.bz2
mpv-a1244111a790bbc4bf91b078ebcad3f415da79da.tar.xz
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.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c19
1 files changed, 10 insertions, 9 deletions
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 <windows.h>
#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: