summaryrefslogtreecommitdiffstats
path: root/options/path.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-09 16:21:44 +0200
committerwm4 <wm4@nowhere>2015-05-09 16:48:05 +0200
commitb6346cd0bafc6a56c29b9c6c56e612e32295ea98 (patch)
tree032def7d3a9f48687038994cfcd6a8cb4a5ce772 /options/path.c
parent34ee78f2cba0510cc37162e89cbdc9d4a9514f92 (diff)
downloadmpv-b6346cd0bafc6a56c29b9c6c56e612e32295ea98.tar.bz2
mpv-b6346cd0bafc6a56c29b9c6c56e612e32295ea98.tar.xz
player: make resuming playlists less noisy in verbose mode
mp_find_config_file() will print the filename lookup and its result in verbose mode. This is wanted, but gets inconvenient when it is done for every playlist entry (for resuming). Lookup the watch_later subdir only once and cache the result instead. This drops the logic for loading the resume file from other locations, which should generally be unnecessary, though might lead to confusion if the user has mixed old and new config paths (which the user shouldn't). Also add a mp_find_user_config_file() function for a more straightforward and reliable way to get actual local configpaths, instead of possibly global and unwritable locations. Also, for symmetry, check the resume option in mp_load_playback_resume() just like mp_check_playlist_resume() does.
Diffstat (limited to 'options/path.c')
-rw-r--r--options/path.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/options/path.c b/options/path.c
index ea36363a90..2895b7224b 100644
--- a/options/path.c
+++ b/options/path.c
@@ -91,6 +91,18 @@ static const char *mp_get_platform_path(void *talloc_ctx,
return NULL;
}
+char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global,
+ const char *filename)
+{
+ void *tmp = talloc_new(NULL);
+ char *res = (char *)mp_get_platform_path(tmp, global, config_dirs[0]);
+ if (res)
+ res = mp_path_join(talloc_ctx, res, filename);
+ talloc_free(tmp);
+ MP_VERBOSE(global, "config file: '%s' -> '%s'\n", filename, res ? res : "-");
+ return res;
+}
+
static char **mp_find_all_config_files_limited(void *talloc_ctx,
struct mpv_global *global,
int max_files,
@@ -316,13 +328,8 @@ void mp_mkdirp(const char *dir)
void mp_mk_config_dir(struct mpv_global *global, char *subdir)
{
- void *tmp = talloc_new(NULL);
- const char *dir = mp_get_platform_path(tmp, global, "home");
-
- if (dir) {
- dir = talloc_asprintf(tmp, "%s/%s", dir, subdir);
+ char *dir = mp_find_user_config_file(NULL, global, subdir);
+ if (dir)
mp_mkdirp(dir);
- }
-
- talloc_free(tmp);
+ talloc_free(dir);
}