mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 21:00:21 +00:00
command: normalize paths for path and track-list/N/external-filename
It's better for API users to actually get predictable results.
This commit is contained in:
1
DOCS/interface-changes/property-paths.txt
Normal file
1
DOCS/interface-changes/property-paths.txt
Normal file
@@ -0,0 +1 @@
|
||||
the `path` and `track-list/N/external-filename` properties now always return a full, absolute path
|
||||
@@ -2109,10 +2109,7 @@ Property list
|
||||
Process-id of mpv.
|
||||
|
||||
``path``
|
||||
Full path of the currently played file. Usually this is exactly the same
|
||||
string you pass on the mpv command line or the ``loadfile`` command, even
|
||||
if it's a relative path. If you expect an absolute path, you will have to
|
||||
determine it yourself, for example by using the ``normalize-path`` command.
|
||||
Full absolute path of the currently played file.
|
||||
|
||||
``stream-open-filename``
|
||||
The full path to the currently played media. This is different from
|
||||
|
||||
@@ -507,7 +507,10 @@ static int mp_property_path(void *ctx, struct m_property *prop,
|
||||
MPContext *mpctx = ctx;
|
||||
if (!mpctx->filename)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
return m_property_strdup_ro(action, arg, mpctx->filename);
|
||||
char *path = mp_normalize_path(NULL, mpctx->filename);
|
||||
int r = m_property_strdup_ro(action, arg, path);
|
||||
talloc_free(path);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int mp_property_filename(void *ctx, struct m_property *prop,
|
||||
@@ -1997,6 +2000,9 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
|
||||
struct MPContext *mpctx = ctx;
|
||||
struct track *track = mpctx->tracks[item];
|
||||
|
||||
char *external_filename = mp_normalize_user_path(NULL, mpctx->global,
|
||||
track->external_filename);
|
||||
|
||||
struct mp_codec_params p =
|
||||
track->stream ? *track->stream->codec : (struct mp_codec_params){0};
|
||||
|
||||
@@ -2048,8 +2054,8 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
|
||||
{"external", SUB_PROP_BOOL(track->is_external)},
|
||||
{"selected", SUB_PROP_BOOL(track->selected)},
|
||||
{"main-selection", SUB_PROP_INT(order), .unavailable = order < 0},
|
||||
{"external-filename", SUB_PROP_STR(track->external_filename),
|
||||
.unavailable = !track->external_filename},
|
||||
{"external-filename", SUB_PROP_STR(external_filename),
|
||||
.unavailable = !external_filename},
|
||||
{"ff-index", SUB_PROP_INT(track->ff_index)},
|
||||
{"hls-bitrate", SUB_PROP_INT(track->hls_bitrate),
|
||||
.unavailable = !track->hls_bitrate},
|
||||
@@ -2123,6 +2129,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_free(external_filename);
|
||||
talloc_free(tag_list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user