summaryrefslogtreecommitdiffstats
path: root/options
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
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')
-rw-r--r--options/path.c23
-rw-r--r--options/path.h6
2 files changed, 21 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);
}
diff --git a/options/path.h b/options/path.h
index 1facea81cf..763a8dda54 100644
--- a/options/path.h
+++ b/options/path.h
@@ -31,6 +31,12 @@ struct mpv_global;
char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global,
const char *filename);
+// Like mp_find_config_file(), but search only the local writable user config
+// dir. Also, this returns a result even if the file does not exist. Calling
+// it with filename="" is equivalent to retrieving the user config dir.
+char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global,
+ const char *filename);
+
// Find all instances of the given config file. Paths are returned in order
// from lowest to highest priority. filename can contain multiple names
// separated with '|', with the first having highest priority.