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
221221 return res;
222222 }
223223
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+
224233 void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir)
225234 {
226235 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
5454 char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
5555 const char *path);
5656
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+
5762 void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir);
5863
5964 #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