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: c201c4874d
This commit is contained in:
llyyr 2024-10-23 20:50:08 +05:30 committed by Kacper Michajłow
parent 851df7088a
commit c5561b8e09
1 changed files with 13 additions and 2 deletions

View File

@ -416,10 +416,21 @@ static bool test_path(struct pl_parser *p, char *path, int autocreate)
if (autocreate & AUTO_ANY) if (autocreate & AUTO_ANY)
return true; 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; 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)) if (autocreate & AUTO_VIDEO && str_in_list(ext, p->mp_opts->video_exts))
return true; return true;
if (autocreate & AUTO_AUDIO && str_in_list(ext, p->mp_opts->audio_exts)) if (autocreate & AUTO_AUDIO && str_in_list(ext, p->mp_opts->audio_exts))