Skip to content

Commit

Permalink
demux_playlist: fix comparison for current file if it's in current dir
Browse files Browse the repository at this point in the history
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: c201c48
  • Loading branch information
llyyr authored and kasper93 committed Oct 24, 2024
1 parent 851df70 commit c5561b8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions demux/demux_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c5561b8

Please sign in to comment.