History

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.

Dudemanguy committed 1 year ago

Commit 6472e451 parent 956cb2c2 files · +14 −0Browse files

Unified · Split

2 files
  1. options/path.c +9 −0
  2. options/path.h +5 −0
options/path.c+9−0
@@ -221,6 +221,15 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global, · 220 unmodified lines
221 return res;221 return res;
222}222}
223 223
224char *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
224void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir)233void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir)
225{234{
226 char *dir = mp_find_user_file(NULL, global, type, subdir);235 char *dir = mp_find_user_file(NULL, global, type, subdir);
options/path.h+5−0
@@ -54,6 +54,11 @@ char **mp_find_all_config_files(void *talloc_ctx, struct mpv_global *global, · 53 unmodified lines
54char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,54char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
55 const char *path);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.
59char *mp_normalize_user_path(void *talloc_ctx, struct mpv_global *global,
60 const char *path);
61
57void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir);62void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir);
58 63
59#endif /* MPLAYER_PATH_H */64#endif /* MPLAYER_PATH_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t