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 committed Oct 23, 2024
1 parent 3d443cb commit a4e9cde
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 a4e9cde

Please sign in to comment.