summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-09 15:26:47 +0200
committerwm4 <wm4@nowhere>2015-05-09 15:26:47 +0200
commit04c02796bd371e65f81a92b853658b8fbadb7ad5 (patch)
tree75b09115e17eedbf06cb3233eb145a5c19f72b58 /options
parent40997b8ae5b4065b3e71d4369eaba14c991e5027 (diff)
downloadmpv-04c02796bd371e65f81a92b853658b8fbadb7ad5.tar.bz2
mpv-04c02796bd371e65f81a92b853658b8fbadb7ad5.tar.xz
path: make mp_path_join accept normal C strings
Instead of bstr. Most callers of this function do not need bstr. The bstr version of this function is now mp_path_join_bstr().
Diffstat (limited to 'options')
-rw-r--r--options/path.c11
-rw-r--r--options/path.h3
2 files changed, 10 insertions, 4 deletions
diff --git a/options/path.c b/options/path.c
index 59bf1a4f85..ea36363a90 100644
--- a/options/path.c
+++ b/options/path.c
@@ -156,13 +156,13 @@ char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
if (bstr_equals0(prefix, "~")) {
res = mp_find_config_file(talloc_ctx, global, rest0);
} else if (bstr_equals0(prefix, "")) {
- res = mp_path_join(talloc_ctx, bstr0(getenv("HOME")), rest);
+ res = mp_path_join_bstr(talloc_ctx, bstr0(getenv("HOME")), rest);
} else if (bstr_eatstart0(&prefix, "~")) {
void *tmp = talloc_new(NULL);
char type[80];
snprintf(type, sizeof(type), "%.*s", BSTR_P(prefix));
const char *p = mp_get_platform_path(tmp, global, type);
- res = mp_path_join(talloc_ctx, bstr0(p), rest);
+ res = mp_path_join_bstr(talloc_ctx, bstr0(p), rest);
talloc_free(tmp);
}
}
@@ -210,7 +210,7 @@ char *mp_splitext(const char *path, bstr *root)
return (char *)split + 1;
}
-char *mp_path_join(void *talloc_ctx, struct bstr p1, struct bstr p2)
+char *mp_path_join_bstr(void *talloc_ctx, struct bstr p1, struct bstr p2)
{
if (p1.len == 0)
return bstrdup0(talloc_ctx, p2);
@@ -238,6 +238,11 @@ char *mp_path_join(void *talloc_ctx, struct bstr p1, struct bstr p2)
have_separator ? "" : "/", BSTR_P(p2));
}
+char *mp_path_join(void *talloc_ctx, const char *p1, const char *p2)
+{
+ return mp_path_join_bstr(talloc_ctx, bstr0(p1), bstr0(p2));
+}
+
char *mp_getcwd(void *talloc_ctx)
{
char *wd = talloc_array(talloc_ctx, char, 20);
diff --git a/options/path.h b/options/path.h
index 7f9c0cb685..1facea81cf 100644
--- a/options/path.h
+++ b/options/path.h
@@ -63,7 +63,8 @@ struct bstr mp_dirname(const char *path);
* for the result. '/' is inserted between the components if needed.
* If p2 is an absolute path then the value of p1 is ignored.
*/
-char *mp_path_join(void *talloc_ctx, struct bstr p1, struct bstr p2);
+char *mp_path_join(void *talloc_ctx, const char *p1, const char *p2);
+char *mp_path_join_bstr(void *talloc_ctx, struct bstr p1, struct bstr p2);
char *mp_getcwd(void *talloc_ctx);