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.
Unified · Split
| @@ -221,6 +221,15 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global, · 220 unmodified lines | ||
| 221 | 221 | return res; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | +char *mp_normalize_user_path(void *talloc_ctx, struct mpv_global *global, | |
| 225 | + const char *path) | |
| 226 | +{ | |
| 227 | + char *expanded = mp_get_user_path(NULL, global, path); | |
| 228 | + char *normalized = mp_normalize_path(talloc_ctx, expanded); | |
| 229 | + talloc_free(expanded); | |
| 230 | + return normalized; | |
| 231 | +} | |
| 232 | + | |
| 224 | 233 | void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir) |
| 225 | 234 | { |
| 226 | 235 | 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, · 53 unmodified lines | ||
| 54 | 54 | char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global, |
| 55 | 55 | const char *path); |
| 56 | 56 | |
| 57 | +// Same as mp_get_user_path but also normalizes the path if it happens to be | |
| 58 | +// relative. Requires a talloc_ctx. | |
| 59 | +char *mp_normalize_user_path(void *talloc_ctx, struct mpv_global *global, | |
| 60 | + const char *path); | |
| 61 | + | |
| 57 | 62 | void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir); |
| 58 | 63 | |
| 59 | 64 | #endif /* MPLAYER_PATH_H */ |