various: remove unneeded option path expansion handling

Same reasoning as the previous commits. This is now handled by the
option system so we can remove the redundancy.
This commit is contained in:
Dudemanguy committed 2025-07-22 17:52:41 +00:00
1 parent 768ad8f035
commit 137d5374bd
14 files changed
+18 -27

No files matched your search

+2 -1
View File
@@ -105,7 +105,7 @@ struct demux_cache *demux_cache_create(struct mpv_global *global,
char *cache_dir = cache->opts->cache_dir;
if (cache_dir && cache_dir[0]) {
cache_dir = mp_get_user_path(NULL, global, cache_dir);
cache_dir = talloc_strdup(NULL, cache_dir);
} else {
cache_dir = mp_find_user_file(NULL, global, "cache", "");
}
@@ -116,6 +116,7 @@ struct demux_cache *demux_cache_create(struct mpv_global *global,
mp_mkdirp(cache_dir);
cache->filename = mp_path_join(cache, cache_dir, "mpv-cache-XXXXXX.dat");
cache->fd = mp_mkostemps(cache->filename, 4, O_CLOEXEC);
talloc_free(cache_dir);
if (cache->fd < 0) {
MP_ERR(cache, "Failed to create cache temporary file.\n");
goto fail;
-2
View File
@@ -1649,8 +1649,6 @@ static bool parse_config_file(struct input_ctx *ictx, char *file)
bool r = false;
void *tmp = talloc_new(NULL);
file = mp_get_user_path(tmp, ictx->global, file);
bstr data = stream_read_file2(file, tmp, STREAM_ORIGIN_DIRECT | STREAM_READ,
ictx->global, 1000000);
if (data.start) {
+1 -1
View File
@@ -389,7 +389,7 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api,
*arg = (struct mp_ipc_ctx){
.log = mp_log_new(arg, global->log, "ipc"),
.client_api = client_api,
.path = mp_get_user_path(arg, global, opts->ipc_path),
.path = talloc_strdup(arg, opts->ipc_path),
.death_pipe = {-1, -1},
};
+2 -1
View File
@@ -6950,8 +6950,9 @@ static void cmd_load_input_conf(void *p)
struct mp_cmd_ctx *cmd = p;
struct MPContext *mpctx = cmd->mpctx;
char *config_file = cmd->args[0].v.s;
char *config_file = mp_get_user_path(NULL, mpctx->global, cmd->args[0].v.s);
cmd->success = mp_input_load_config_file(mpctx->input, config_file);
talloc_free(config_file);
}
static void cmd_load_script(void *p)
+1 -1
View File
@@ -201,7 +201,7 @@ char *mp_get_playback_resume_dir(struct MPContext *mpctx)
{
char *wl_dir = mpctx->opts->watch_later_dir;
if (wl_dir && wl_dir[0]) {
wl_dir = mp_get_user_path(mpctx, mpctx->global, wl_dir);
wl_dir = talloc_strdup(mpctx, wl_dir);
} else {
wl_dir = mp_find_user_file(mpctx, mpctx->global, "state", MP_WATCH_LATER_CONF);
}
+1 -2
View File
@@ -1545,8 +1545,7 @@ static void append_to_watch_history(struct MPContext *mpctx)
return;
void *ctx = talloc_new(NULL);
char *history_path = mp_get_user_path(ctx, mpctx->global,
mpctx->opts->watch_history_path);
char *history_path = mpctx->opts->watch_history_path;
char *history_path_dir = bstrto0(ctx, mp_dirname(history_path));
mp_mkdirp(history_path_dir);
-1
View File
@@ -297,7 +297,6 @@ static char *gen_fname(struct mp_cmd_ctx *cmd, const char *file_ext)
char *dir = ctx->mpctx->opts->screenshot_dir;
if (dir && dir[0]) {
void *t = fname;
dir = mp_get_user_path(t, ctx->mpctx->global, dir);
fname = mp_path_join(NULL, dir, fname);
mp_mkdirp(dir);
+1 -1
View File
@@ -280,7 +280,7 @@ bool mp_load_scripts(struct MPContext *mpctx)
char **files = mpctx->opts->script_files;
for (int n = 0; files && files[n]; n++) {
if (files[n][0])
ok &= mp_load_user_script(mpctx, files[n]) >= 0;
ok &= mp_load_script(mpctx, files[n]) >= 0;
}
if (!mpctx->opts->auto_load_scripts)
return ok;
+1 -1
View File
@@ -131,7 +131,7 @@ ASS_Library *mp_ass_init(struct mpv_global *global,
struct osd_style_opts *opts, struct mp_log *log)
{
char *path = opts->fonts_dir && opts->fonts_dir[0] ?
mp_get_user_path(NULL, global, opts->fonts_dir) :
talloc_strdup(NULL, opts->fonts_dir) :
mp_find_config_file(NULL, global, "fonts");
mp_dbg(log, "ASS library version: 0x%x (runtime 0x%x)\n",
(unsigned)LIBASS_VERSION, ass_library_version());
+1 -1
View File
@@ -750,7 +750,7 @@ static struct mp_filter *vf_vapoursynth_create(struct mp_filter *parent,
MP_FATAL(p, "'file' parameter must be set.\n");
goto error;
}
p->script_path = mp_get_user_path(p, f->global, p->opts->file);
p->script_path = talloc_strdup(p, p->opts->file);
p->max_requests = p->opts->maxrequests;
if (p->max_requests < 0)
+2 -3
View File
@@ -73,11 +73,10 @@ static void load_profile(struct gl_lcms *p)
if (!p->opts->profile || !p->opts->profile[0])
return;
char *fname = mp_get_user_path(NULL, p->global, p->opts->profile);
char *fname = p->opts->profile;
MP_VERBOSE(p, "Opening ICC profile '%s'\n", fname);
struct bstr iccdata = stream_read_file(fname, p, p->global,
100000000); // 100 MB
talloc_free(fname);
if (!iccdata.len)
return;
@@ -365,7 +364,7 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d,
char *cache_dir = p->opts->cache_dir;
if (cache_dir && cache_dir[0]) {
cache_dir = mp_get_user_path(tmp, p->global, cache_dir);
cache_dir = talloc_strdup(tmp, cache_dir);
} else {
cache_dir = mp_find_user_file(tmp, p->global, "cache", "");
}
+1 -1
View File
@@ -559,7 +559,7 @@ void gl_sc_set_cache_dir(struct gl_shader_cache *sc, char *dir)
{
talloc_free(sc->cache_dir);
if (dir && dir[0]) {
dir = mp_get_user_path(NULL, sc->global, dir);
dir = talloc_strdup(NULL, dir);
} else {
dir = mp_find_user_file(NULL, sc->global, "cache", "");
}
+1 -3
View File
@@ -583,9 +583,7 @@ static struct bstr load_cached_file(struct gl_video *p, const char *path)
return p->files[n].body;
}
// not found -> load it
char *fname = mp_get_user_path(NULL, p->global, path);
struct bstr s = stream_read_file(fname, p, p->global, 1000000000); // 1GB
talloc_free(fname);
struct bstr s = stream_read_file(path, p, p->global, 1000000000); // 1GB
if (s.len) {
struct cached_file new = {
.path = talloc_strdup(p, path),
+4 -8
View File
@@ -1809,7 +1809,7 @@ static void cache_init(struct vo *vo, struct cache *cache, size_t max_size,
char *dir;
if (dir_opt && dir_opt[0]) {
dir = mp_get_user_path(vo, p->global, dir_opt);
dir = talloc_strdup(vo, dir_opt);
} else {
dir = mp_find_user_file(vo, p->global, "cache", "");
}
@@ -2111,9 +2111,7 @@ static const struct pl_hook *load_hook(struct priv *p, const char *path)
return p->user_hooks[i].hook;
}
char *fname = mp_get_user_path(NULL, p->global, path);
bstr shader = stream_read_file(fname, p, p->global, 1000000000); // 1GB
talloc_free(fname);
bstr shader = stream_read_file(path, p, p->global, 1000000000); // 1GB
const struct pl_hook *hook = NULL;
if (shader.len)
@@ -2156,10 +2154,9 @@ static void update_icc_opts(struct priv *p, const struct mp_icc_opts *opts)
if (p->icc_path && strcmp(opts->profile, p->icc_path) == 0)
return; // ICC profile hasn't changed
char *fname = mp_get_user_path(NULL, p->global, opts->profile);
char *fname = opts->profile;
MP_VERBOSE(p, "Opening ICC profile '%s'\n", fname);
struct bstr icc = stream_read_file(fname, p, p->global, 100000000); // 100 MB
talloc_free(fname);
update_icc(p, icc);
// Update cached path
@@ -2182,7 +2179,7 @@ static void update_lut(struct priv *p, struct user_lut *lut)
talloc_replace(p, lut->path, lut->opt);
// Load LUT file
char *fname = mp_get_user_path(NULL, p->global, lut->path);
char *fname = lut->path;
MP_VERBOSE(p, "Loading custom LUT '%s'\n", fname);
const int lut_max_size = 1536 << 20; // 1.5 GiB, matches lut cache limit
struct bstr lutdata = stream_read_file(fname, NULL, p->global, lut_max_size);
@@ -2192,7 +2189,6 @@ static void update_lut(struct priv *p, struct user_lut *lut)
} else {
lut->lut = pl_lut_parse_cube(p->pllog, lutdata.start, lutdata.len);
}
talloc_free(fname);
talloc_free(lutdata.start);
}