mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 04:51:52 +00:00
command: add property returning current working directory
Requested; fixes #1717.
This commit is contained in:
parent
81a63545a0
commit
36c4ac8464
@ -1693,6 +1693,10 @@ Property list
|
||||
Return the audio device selected by the AO driver (only implemented for
|
||||
some drivers: currently only ``coreaudio``).
|
||||
|
||||
``working-directory``
|
||||
Return the working directory of the mpv process. Can be useful for JSON IPC
|
||||
users, because the command line player usually works with relative paths.
|
||||
|
||||
``mpv-version``
|
||||
Return the mpv version/copyright string. Depending on how the binary was
|
||||
built, it might contain either a release version, or just a git hash.
|
||||
|
@ -3149,6 +3149,24 @@ static int mp_property_packet_bitrate(void *ctx, struct m_property *prop,
|
||||
return m_property_int64_ro(action, arg, r[type] * 8 / 1000.0 + 0.5);
|
||||
}
|
||||
|
||||
static int mp_property_cwd(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
switch (action) {
|
||||
case M_PROPERTY_GET: {
|
||||
char *cwd = mp_getcwd(NULL);
|
||||
if (!cwd)
|
||||
return M_PROPERTY_ERROR;
|
||||
*(char **)arg = cwd;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
case M_PROPERTY_GET_TYPE:
|
||||
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int mp_property_version(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
@ -3524,6 +3542,8 @@ static const struct m_property mp_properties[] = {
|
||||
{"display-names", mp_property_display_names},
|
||||
{"display-fps", mp_property_display_fps},
|
||||
|
||||
{"working-directory", mp_property_cwd},
|
||||
|
||||
{"mpv-version", mp_property_version},
|
||||
{"mpv-configuration", mp_property_configuration},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user