From b2c2fe7a3782c1c47ba3bee6481b0c2f8d41ef22 Mon Sep 17 00:00:00 2001 From: elevengu Date: Wed, 22 May 2013 12:31:38 -0300 Subject: core: support mpv directory itself as a valid location for config files on Windows This prefers ./ on Windows if-and-only-if the file being searched for already exists there. (If the mpv directory is non-writable, the result is still intended behavior.) This change is transparent to most users because the user has to move the config files there intentionally, and if anything, not being detected would be the surprising behavior. --- core/path.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'core') diff --git a/core/path.c b/core/path.c index e373df21ab..1cff719041 100644 --- a/core/path.c +++ b/core/path.c @@ -83,26 +83,39 @@ char *mp_find_user_config_file(const char *filename) static char *config_dir = ".mpv"; #endif #if defined(__MINGW32__) || defined(__CYGWIN__) + char *temp = NULL; char exedir[260]; + /* Hack to get fonts etc. loaded outside of Cygwin environment. */ + int i, imax = 0; + int len = (int)GetModuleFileNameA(NULL, exedir, 260); + for (i = 0; i < len; i++) + if (exedir[i] == '\\') { + exedir[i] = '/'; + imax = i; + } + exedir[imax] = '\0'; + + if (filename) + temp = mp_path_join(NULL, bstr0(exedir), bstr0(filename)); + + if (temp && mp_path_exists(temp) && !mp_path_isdir(temp)) { + homedir = exedir; + config_dir = ""; + } + else #endif if ((homedir = getenv("MPV_HOME")) != NULL) { config_dir = ""; } else if ((homedir = getenv("HOME")) == NULL) { #if defined(__MINGW32__) || defined(__CYGWIN__) - /* Hack to get fonts etc. loaded outside of Cygwin environment. */ - int i, imax = 0; - int len = (int)GetModuleFileNameA(NULL, exedir, 260); - for (i = 0; i < len; i++) - if (exedir[i] == '\\') { - exedir[i] = '/'; - imax = i; - } - exedir[imax] = '\0'; homedir = exedir; #else return NULL; #endif } +#if defined(__MINGW32__) || defined(__CYGWIN__) + talloc_free(temp); +#endif if (filename) { char * temp = mp_path_join(NULL, bstr0(homedir), bstr0(config_dir)); -- cgit v1.2.3