mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
options/path: add mp_normalize_user_path shorthand
Expanding a path and then normalizing it is probably a common shorthand. The reason to not incorporate this directly into mp_normalize_path is because it requires the global struct which is out of scope for path_utils so use this wrapper instead.
This commit is contained in:
parent
956cb2c49f
commit
6472e45e8b
@ -221,6 +221,15 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
|
||||
return res;
|
||||
}
|
||||
|
||||
char *mp_normalize_user_path(void *talloc_ctx, struct mpv_global *global,
|
||||
const char *path)
|
||||
{
|
||||
char *expanded = mp_get_user_path(NULL, global, path);
|
||||
char *normalized = mp_normalize_path(talloc_ctx, expanded);
|
||||
talloc_free(expanded);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir)
|
||||
{
|
||||
char *dir = mp_find_user_file(NULL, global, type, subdir);
|
||||
|
@ -54,6 +54,11 @@ char **mp_find_all_config_files(void *talloc_ctx, struct mpv_global *global,
|
||||
char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
|
||||
const char *path);
|
||||
|
||||
// Same as mp_get_user_path but also normalizes the path if it happens to be
|
||||
// relative. Requires a talloc_ctx.
|
||||
char *mp_normalize_user_path(void *talloc_ctx, struct mpv_global *global,
|
||||
const char *path);
|
||||
|
||||
void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir);
|
||||
|
||||
#endif /* MPLAYER_PATH_H */
|
||||
|
Loading…
Reference in New Issue
Block a user