mirror of
https://github.com/mpv-player/mpv.git
synced 2026-05-07 20:02:49 +00:00
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.
This commit is contained in:
+22
-9
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user