From b6346cd0bafc6a56c29b9c6c56e612e32295ea98 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 9 May 2015 16:21:44 +0200 Subject: 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. --- options/path.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'options/path.c') 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); } -- cgit v1.2.3