summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorelevengu <enhasa@live.com>2013-05-22 12:31:38 -0300
committerwm4 <wm4@nowhere>2013-05-23 01:01:41 +0200
commitb2c2fe7a3782c1c47ba3bee6481b0c2f8d41ef22 (patch)
treebc368f69e19eec8b91adc473bbb150260ed13b25 /core
parent3cae1b9fc96ff628bfdb16c47ca020bbcd16b680 (diff)
downloadmpv-b2c2fe7a3782c1c47ba3bee6481b0c2f8d41ef22.tar.bz2
mpv-b2c2fe7a3782c1c47ba3bee6481b0c2f8d41ef22.tar.xz
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.
Diffstat (limited to 'core')
-rw-r--r--core/path.c31
1 files changed, 22 insertions, 9 deletions
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));