summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/playlist.c2
-rw-r--r--demux/demux_cue.c4
-rw-r--r--demux/demux_edl.c2
-rw-r--r--demux/demux_mkv_timeline.c2
-rw-r--r--demux/demux_playlist.c2
-rw-r--r--options/path.c11
-rw-r--r--options/path.h3
-rw-r--r--osdep/path-macosx.m4
-rw-r--r--osdep/path-win.c2
-rw-r--r--player/configfiles.c4
-rw-r--r--player/lua.c4
-rw-r--r--player/screenshot.c2
-rw-r--r--player/scripting.c2
-rw-r--r--stream/stream_bluray.c4
-rw-r--r--stream/stream_dvdnav.c4
-rw-r--r--sub/find_subfiles.c6
-rw-r--r--video/out/gl_lcms.c2
-rw-r--r--video/out/vo_image.c2
18 files changed, 34 insertions, 28 deletions
diff --git a/common/playlist.c b/common/playlist.c
index bb849f18a0..df3b65fbbc 100644
--- a/common/playlist.c
+++ b/common/playlist.c
@@ -199,7 +199,7 @@ void playlist_add_base_path(struct playlist *pl, bstr base_path)
return;
for (struct playlist_entry *e = pl->first; e; e = e->next) {
if (!mp_is_url(bstr0(e->filename))) {
- char *new_file = mp_path_join(e, base_path, bstr0(e->filename));
+ char *new_file = mp_path_join_bstr(e, base_path, bstr0(e->filename));
talloc_free(e->filename);
e->filename = new_file;
}
diff --git a/demux/demux_cue.c b/demux/demux_cue.c
index 93518c9336..c493647e09 100644
--- a/demux/demux_cue.c
+++ b/demux/demux_cue.c
@@ -226,7 +226,7 @@ static bool open_source(struct timeline *tl, struct bstr filename)
if (!base_filename.len) {
MP_WARN(tl, "CUE: Invalid audio filename in .cue file!\n");
} else {
- char *fullname = mp_path_join(ctx, dirname, base_filename);
+ char *fullname = mp_path_join_bstr(ctx, dirname, base_filename);
if (try_open(tl, fullname)) {
res = true;
goto out;
@@ -252,7 +252,7 @@ static bool open_source(struct timeline *tl, struct bstr filename)
MP_WARN(tl, "CUE: No useful audio filename "
"in .cue file found, trying with '%s' instead!\n",
dename0);
- if (try_open(tl, mp_path_join(ctx, dirname, dename))) {
+ if (try_open(tl, mp_path_join_bstr(ctx, dirname, dename))) {
res = true;
break;
}
diff --git a/demux/demux_edl.c b/demux/demux_edl.c
index 3bda4f44b2..fc0db2f2fa 100644
--- a/demux/demux_edl.c
+++ b/demux/demux_edl.c
@@ -272,7 +272,7 @@ static void fix_filenames(struct tl_parts *parts, char *source_path)
for (int n = 0; n < parts->num_parts; n++) {
struct tl_part *part = &parts->parts[n];
char *filename = mp_basename(part->filename); // plain filename only
- part->filename = mp_path_join(parts, dirname, bstr0(filename));
+ part->filename = mp_path_join_bstr(parts, dirname, bstr0(filename));
}
}
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index c7310a66cf..e1491b631d 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -118,7 +118,7 @@ static char **find_files(const char *original_file)
if (!strcmp(ep->d_name, basename))
continue;
- char *name = mp_path_join(results, directory, bstr0(ep->d_name));
+ char *name = mp_path_join_bstr(results, directory, bstr0(ep->d_name));
char *s1 = ep->d_name;
char *s2 = basename;
int matchlen = 0;
diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c
index 6f73bea5ba..0479694b34 100644
--- a/demux/demux_playlist.c
+++ b/demux/demux_playlist.c
@@ -245,7 +245,7 @@ static int parse_dir(struct pl_parser *p)
qsort(files, num_files, sizeof(files[0]), cmp_filename);
for (int n = 0; n < num_files; n++)
- playlist_add_file(p->pl, mp_path_join(p, bstr0(path), bstr0(files[n])));
+ playlist_add_file(p->pl, mp_path_join(p, path, files[n]));
closedir(dp);
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);
diff --git a/osdep/path-macosx.m b/osdep/path-macosx.m
index 52e2a2c771..f011289e36 100644
--- a/osdep/path-macosx.m
+++ b/osdep/path-macosx.m
@@ -28,7 +28,7 @@ const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type)
[pool release];
return res;
}
- if (strcmp(type, "desktop") == 0)
- return mp_path_join(talloc_ctx, bstr0(getenv("HOME")), bstr0("Desktop"));
+ if (strcmp(type, "desktop") == 0 && getenv("HOME"))
+ return mp_path_join(talloc_ctx, getenv("HOME"), "Desktop");
return NULL;
}
diff --git a/osdep/path-win.c b/osdep/path-win.c
index db6698102f..d0c29556d1 100644
--- a/osdep/path-win.c
+++ b/osdep/path-win.c
@@ -61,7 +61,7 @@ static char *mp_get_win_shell_dir(void *talloc_ctx, int folder)
static char *mp_get_win_app_dir(void *talloc_ctx)
{
char *path = mp_get_win_shell_dir(talloc_ctx, CSIDL_APPDATA);
- return path ? mp_path_join(talloc_ctx, bstr0(path), bstr0("mpv")) : NULL;
+ return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL;
}
const char *mp_get_platform_path_win(void *talloc_ctx, const char *type)
diff --git a/player/configfiles.c b/player/configfiles.c
index 52cd837ab7..984a0fd02e 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -117,7 +117,7 @@ static void mp_load_per_file_config(struct MPContext *mpctx)
char *name = mp_basename(cfg);
bstr dir = mp_dirname(cfg);
- char *dircfg = mp_path_join(NULL, dir, bstr0("mpv.conf"));
+ char *dircfg = mp_path_join_bstr(NULL, dir, bstr0("mpv.conf"));
try_load_config(mpctx, dircfg, FILE_LOCAL_FLAGS);
talloc_free(dircfg);
@@ -181,7 +181,7 @@ static char *mp_get_playback_resume_config_filename(struct mpv_global *global,
char *cwd = mp_getcwd(tmp);
if (!cwd)
goto exit;
- realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname));
+ realpath = mp_path_join(tmp, cwd, fname);
}
}
if (bstr_startswith0(bfname, "dvd://"))
diff --git a/player/lua.c b/player/lua.c
index 8cfcd059a4..2e00f79dda 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -280,7 +280,7 @@ static void set_path(lua_State *L)
char **luadir = mp_find_all_config_files(tmp, get_mpctx(L)->global, "scripts");
for (int i = 0; luadir && luadir[i]; i++) {
newpath = talloc_asprintf_append(newpath, ";%s",
- mp_path_join(tmp, bstr0(luadir[i]), bstr0("?.lua")));
+ mp_path_join(tmp, luadir[i], "?.lua"));
}
lua_pushstring(L, newpath); // package path newpath
@@ -1142,7 +1142,7 @@ static int script_join_path(lua_State *L)
{
const char *p1 = luaL_checkstring(L, 1);
const char *p2 = luaL_checkstring(L, 2);
- char *r = mp_path_join(NULL, bstr0(p1), bstr0(p2));
+ char *r = mp_path_join(NULL, p1, p2);
lua_pushstring(L, r);
talloc_free(r);
return 1;
diff --git a/player/screenshot.c b/player/screenshot.c
index 0449dfb5a1..f30ccf9581 100644
--- a/player/screenshot.c
+++ b/player/screenshot.c
@@ -284,7 +284,7 @@ static char *gen_fname(screenshot_ctx *ctx, const char *file_ext)
if (dir && dir[0]) {
void *t = fname;
dir = mp_get_user_path(t, ctx->mpctx->global, dir);
- fname = mp_path_join(NULL, bstr0(dir), bstr0(fname));
+ fname = mp_path_join(NULL, dir, fname);
talloc_free(t);
mp_mkdirp(dir);
diff --git a/player/scripting.c b/player/scripting.c
index eafe568c56..3ae97193ba 100644
--- a/player/scripting.c
+++ b/player/scripting.c
@@ -163,7 +163,7 @@ static char **list_script_files(void *talloc_ctx, char *path)
return NULL;
struct dirent *ep;
while ((ep = readdir(dp))) {
- char *fname = mp_path_join(talloc_ctx, bstr0(path), bstr0(ep->d_name));
+ char *fname = mp_path_join(talloc_ctx, path, ep->d_name);
struct stat s;
if (!stat(fname, &s) && S_ISREG(s.st_mode))
MP_TARRAY_APPEND(talloc_ctx, files, count, fname);
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index adc2e5828b..117b0cc205 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -891,9 +891,9 @@ static int bdmv_dir_stream_open(stream_t *stream)
// directory containing MovieObject.bdmv, or that file itself.
if (!check_bdmv(path)) {
// On UNIX, just assume the filename has always this case.
- char *npath = mp_path_join(priv, bstr0(path), bstr0("MovieObject.bdmv"));
+ char *npath = mp_path_join(priv, path, "MovieObject.bdmv");
if (!check_bdmv(npath)) {
- npath = mp_path_join(priv, bstr0(path), bstr0("BDMV/MovieObject.bdmv"));
+ npath = mp_path_join(priv, path, "BDMV/MovieObject.bdmv");
if (!check_bdmv(npath))
goto unsupported;
}
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index 095ba98ddf..e2ea93d200 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -835,9 +835,9 @@ static int ifo_dvdnav_stream_open(stream_t *stream)
// directory containing VIDEO_TS.IFO, or that file itself.
if (!check_ifo(path)) {
// On UNIX, just assume the filename is always uppercase.
- char *npath = mp_path_join(priv, bstr0(path), bstr0("VIDEO_TS.IFO"));
+ char *npath = mp_path_join(priv, path, "VIDEO_TS.IFO");
if (!check_ifo(npath)) {
- npath = mp_path_join(priv, bstr0(path), bstr0("VIDEO_TS/VIDEO_TS.IFO"));
+ npath = mp_path_join(priv, path, "VIDEO_TS/VIDEO_TS.IFO");
if (!check_ifo(npath))
goto unsupported;
}
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c
index 10dd479a07..bdeef0fadc 100644
--- a/sub/find_subfiles.c
+++ b/sub/find_subfiles.c
@@ -188,7 +188,7 @@ static void append_dir_subtitles(struct mpv_global *global,
if (prio) {
prio += prio;
- char *subpath = mp_path_join(*slist, path, dename);
+ char *subpath = mp_path_join_bstr(*slist, path, dename);
if (mp_path_exists(subpath)) {
MP_GROW_ARRAY(*slist, *nsub);
struct subfn *sub = *slist + (*nsub)++;
@@ -256,8 +256,8 @@ struct subfn *find_external_files(struct mpv_global *global, const char *fname)
// Load subtitles in dirs specified by sub-paths option
if (opts->sub_paths) {
for (int i = 0; opts->sub_paths[i]; i++) {
- char *path = mp_path_join(slist, mp_dirname(fname),
- bstr0(opts->sub_paths[i]));
+ char *path = mp_path_join_bstr(slist, mp_dirname(fname),
+ bstr0(opts->sub_paths[i]));
append_dir_subtitles(global, &slist, &n, bstr0(path), fname, 0);
}
}
diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c
index aca4825917..b7ee51360c 100644
--- a/video/out/gl_lcms.c
+++ b/video/out/gl_lcms.c
@@ -230,7 +230,7 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d)
cache_file = talloc_strdup(tmp, "");
for (int i = 0; i < sizeof(hash); i++)
cache_file = talloc_asprintf_append(cache_file, "%02X", hash[i]);
- cache_file = mp_path_join(tmp, bstr0(cache_dir), bstr0(cache_file));
+ cache_file = mp_path_join(tmp, cache_dir, cache_file);
mp_mkdirp(cache_dir);
}
diff --git a/video/out/vo_image.c b/video/out/vo_image.c
index 4a87d82deb..e8f9e1f063 100644
--- a/video/out/vo_image.c
+++ b/video/out/vo_image.c
@@ -95,7 +95,7 @@ static void flip_page(struct vo *vo)
image_writer_file_ext(p->opts));
if (p->outdir && strlen(p->outdir))
- filename = mp_path_join(t, bstr0(p->outdir), bstr0(filename));
+ filename = mp_path_join(t, p->outdir, filename);
MP_INFO(vo, "Saving %s\n", filename);
write_image(p->current, p->opts, filename, vo->log);