summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options/path.c12
-rw-r--r--options/path.h13
-rw-r--r--player/configfiles.c6
3 files changed, 16 insertions, 15 deletions
diff --git a/options/path.c b/options/path.c
index 4dfe36bd2d..bd8adf6d81 100644
--- a/options/path.c
+++ b/options/path.c
@@ -102,15 +102,15 @@ 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)
+char *mp_find_user_file(void *talloc_ctx, struct mpv_global *global,
+ const char *type, const char *filename)
{
void *tmp = talloc_new(NULL);
- char *res = (char *)mp_get_platform_path(tmp, global, config_dirs[0]);
+ char *res = (char *)mp_get_platform_path(tmp, global, type);
if (res)
res = mp_path_join(talloc_ctx, res, filename);
talloc_free(tmp);
- MP_DBG(global, "config path: '%s' -> '%s'\n", filename, res ? res : "-");
+ MP_DBG(global, "path: '%s' -> '%s'\n", filename, res ? res : "-");
return res;
}
@@ -378,9 +378,9 @@ void mp_mkdirp(const char *dir)
talloc_free(path);
}
-void mp_mk_config_dir(struct mpv_global *global, char *subdir)
+void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir)
{
- char *dir = mp_find_user_config_file(NULL, global, subdir);
+ char *dir = mp_find_user_file(NULL, global, type, subdir);
if (dir)
mp_mkdirp(dir);
talloc_free(dir);
diff --git a/options/path.h b/options/path.h
index 19f4fb5909..66ddcdc798 100644
--- a/options/path.h
+++ b/options/path.h
@@ -34,11 +34,12 @@ void mp_init_paths(struct mpv_global *global, struct MPOpts *opts);
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);
+// Search for local writable user files within a specific kind of user dir
+// as documented in osdep/path.h. This returns a result even if the file does
+// not exist. Calling it with filename="" is equivalent to retrieving the path
+// to the dir.
+char *mp_find_user_file(void *talloc_ctx, struct mpv_global *global,
+ const char *type, 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
@@ -90,6 +91,6 @@ bool mp_is_url(bstr path);
bstr mp_split_proto(bstr path, bstr *out_url);
void mp_mkdirp(const char *dir);
-void mp_mk_config_dir(struct mpv_global *global, char *subdir);
+void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir);
#endif /* MPLAYER_PATH_H */
diff --git a/player/configfiles.c b/player/configfiles.c
index 41c22ed2b9..9de7e36ec7 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -63,7 +63,7 @@ void mp_parse_cfgfiles(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
- mp_mk_config_dir(mpctx->global, "");
+ mp_mk_user_dir(mpctx->global, "home", "");
char *p1 = mp_get_user_path(NULL, mpctx->global, "~~home/");
char *p2 = mp_get_user_path(NULL, mpctx->global, "~~old_home/");
@@ -226,7 +226,7 @@ static char *mp_get_playback_resume_config_filename(struct MPContext *mpctx,
if (!mpctx->cached_watch_later_configdir) {
mpctx->cached_watch_later_configdir =
- mp_find_user_config_file(mpctx, mpctx->global, MP_WATCH_LATER_CONF);
+ mp_find_user_file(mpctx, mpctx->global, "home", MP_WATCH_LATER_CONF);
}
if (mpctx->cached_watch_later_configdir)
@@ -292,7 +292,7 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
if (!conffile)
goto exit;
- mp_mk_config_dir(mpctx->global, mpctx->cached_watch_later_configdir);
+ mp_mk_user_dir(mpctx->global, "home", mpctx->cached_watch_later_configdir);
MP_INFO(mpctx, "Saving state.\n");