Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions misc/path_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@

char *mp_basename(const char *path)
{
if (mp_is_url(bstr0(path)))
return (char *)path;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as an aside: why does this function not return a const char*?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it did until 962eec0 with no explanation for the change. Anyway, I can change it after this PR.


char *s;

#if HAVE_DOS_PATHS
if (!mp_is_url(bstr0(path))) {
s = strrchr(path, '\\');
if (s)
path = s + 1;
s = strrchr(path, ':');
if (s)
path = s + 1;
}
s = strrchr(path, '\\');
if (s)
path = s + 1;
s = strrchr(path, ':');
if (s)
path = s + 1;
#endif
s = strrchr(path, '/');
return s ? s + 1 : (char *)path;
Expand Down
9 changes: 3 additions & 6 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3508,12 +3508,9 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
const char *reset = pl->current == e ? get_style_reset(mpctx) : "";
char *p = e->title;
if (!p || mpctx->opts->playlist_entry_name > 0) {
p = e->filename;
if (!mp_is_url(bstr0(p))) {
char *s = mp_basename(e->filename);
if (s[0])
p = s;
}
p = mp_basename(e->filename);
if (!p[0])
p = e->filename;
}
if (!e->title || p == e->title || mpctx->opts->playlist_entry_name == 1) {
res = talloc_asprintf_append(res, "%s%s\n", p, reset);
Expand Down
10 changes: 4 additions & 6 deletions player/configfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ static char *mp_get_playback_resume_config_filename(struct MPContext *mpctx,
char *res = NULL;
void *tmp = talloc_new(NULL);
const char *path = NULL;
if (mp_is_url(bstr0(fname))) {
path = fname;
} else if (opts->ignore_path_in_watch_later_config) {
if (opts->ignore_path_in_watch_later_config) {
path = mp_basename(fname);
} else {
path = mp_normalize_path(tmp, fname);
Expand Down Expand Up @@ -255,7 +253,7 @@ static bool needs_config_quoting(const char *s)

static void write_filename(struct MPContext *mpctx, FILE *file, char *filename)
{
if (mpctx->opts->ignore_path_in_watch_later_config && !mp_is_url(bstr0(filename)))
if (mpctx->opts->ignore_path_in_watch_later_config)
filename = mp_basename(filename);

if (mpctx->opts->write_filename_in_watch_later_config) {
Expand Down Expand Up @@ -287,7 +285,7 @@ static void write_redirect(struct MPContext *mpctx, char *path)

static void write_redirects_for_parent_dirs(struct MPContext *mpctx, char *path)
{
if (mp_is_url(bstr0(path)) || mpctx->opts->ignore_path_in_watch_later_config)
if (mpctx->opts->ignore_path_in_watch_later_config)
return;

// Write redirect entries for the file's parent directories to allow
Expand Down Expand Up @@ -412,7 +410,7 @@ void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file)
unlink(fname);
talloc_free(fname);

if (mp_is_url(bstr0(path)) || mpctx->opts->ignore_path_in_watch_later_config)
if (mpctx->opts->ignore_path_in_watch_later_config)
goto exit;

bstr dir = mp_dirname(path);
Expand Down
7 changes: 2 additions & 5 deletions player/lua/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ mp.add_key_binding(nil, "select-playlist", function ()
for i, entry in ipairs(mp.get_property_native("playlist")) do
playlist[i] = entry.title
if not playlist[i] or show ~= "title" then
playlist[i] = entry.filename
if not playlist[i]:find("://") then
playlist[i] = select(2, utils.split_path(
playlist[i]:gsub(trailing_slash_pattern, "")))
end
playlist[i] = select(2, utils.split_path(
entry.filename:gsub(trailing_slash_pattern, "")))
end
if entry.title and show == "both" then
playlist[i] = string.format("%s (%s)", entry.title, playlist[i])
Expand Down
Loading