From c5561b8e09d2510bd3eff2d1869476dbf2b216c6 Mon Sep 17 00:00:00 2001 From: llyyr Date: Wed, 23 Oct 2024 20:50:08 +0530 Subject: [PATCH] demux_playlist: fix comparison for current file if it's in current dir When the file is in the current working directory, stream->path points the path user passed as arg, so it may or may not include './'. Strip it from both to make the comparison work Fixes: c201c4874def40b30e5017728bbfbe04ad065dcc --- demux/demux_playlist.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 081f9f572d..4c0859df3b 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -416,10 +416,21 @@ static bool test_path(struct pl_parser *p, char *path, int autocreate) if (autocreate & AUTO_ANY) return true; - if (!strcmp(path, p->real_stream->path)) + bstr bpath = bstr0(path); + bstr bstream_path = bstr0(p->real_stream->path); + + // When opening a file from cwd, 'path' starts with "./" while stream->path + // matches what the user passed as arg. So it may or not not contain ./. + // Strip it from both to make the comparison work. + if (!mp_path_is_absolute(bstream_path)) { + bstr_eatstart0(&bpath, "./"); + bstr_eatstart0(&bstream_path, "./"); + } + + if (!bstrcmp(bpath, bstream_path)) return true; - bstr ext = bstr_get_ext(bstr0(path)); + bstr ext = bstr_get_ext(bpath); if (autocreate & AUTO_VIDEO && str_in_list(ext, p->mp_opts->video_exts)) return true; if (autocreate & AUTO_AUDIO && str_in_list(ext, p->mp_opts->audio_exts))