From dc6f8d4a0af27f32ff9d8df86cae6ad2df4aefcc Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 11 Aug 2016 22:40:00 +0200 Subject: command: add a property that returns filename without extension Requested. Fixes #3404. --- player/command.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index d8f4f83529..584cc11cdc 100644 --- a/player/command.c +++ b/player/command.c @@ -346,7 +346,19 @@ static int mp_property_filename(void *ctx, struct m_property *prop, if (mp_is_url(bstr0(filename))) mp_url_unescape_inplace(filename); char *f = (char *)mp_basename(filename); - int r = m_property_strdup_ro(action, arg, f[0] ? f : filename); + if (!f[0]) + f = filename; + if (action == M_PROPERTY_KEY_ACTION) { + struct m_property_action_arg *ka = arg; + if (strcmp(ka->key, "no-ext") == 0) { + action = ka->action; + arg = ka->arg; + bstr root; + if (mp_splitext(f, &root)) + f = bstrto0(filename, root); + } + } + int r = m_property_strdup_ro(action, arg, f); talloc_free(filename); return r; } -- cgit v1.2.3