summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-08 21:07:10 +0100
committerwm4 <wm4@nowhere>2014-01-08 21:09:01 +0100
commit59c6fa220158794791b5e1674c4aa1e1a439c2c8 (patch)
tree192edbeeccc331ec509da91879a165b5d19fb90f /player
parent3e6fdc94d6b9f5ea4390f821c184b5e7a5e0d508 (diff)
downloadmpv-59c6fa220158794791b5e1674c4aa1e1a439c2c8.tar.bz2
mpv-59c6fa220158794791b5e1674c4aa1e1a439c2c8.tar.xz
screenshot: add format specifiers to get file directory path
Useful if you want to put the screenshot into the same directory as the file that is being played.
Diffstat (limited to 'player')
-rw-r--r--player/screenshot.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/player/screenshot.c b/player/screenshot.c
index 500960aee4..d6aa81af84 100644
--- a/player/screenshot.c
+++ b/player/screenshot.c
@@ -178,6 +178,27 @@ static char *create_fname(struct MPContext *mpctx, char *template,
}
break;
}
+ case 'x':
+ case 'X': {
+ char *fallback = "";
+ if (fmt == 'X') {
+ if (template[0] != '{')
+ goto error_exit;
+ char *end = strchr(template, '}');
+ if (!end)
+ goto error_exit;
+ fallback = talloc_strndup(res, template + 1, end - template - 1);
+ template = end + 1;
+ }
+ if (!mpctx->filename || mp_is_url(bstr0(mpctx->filename))) {
+ res = talloc_strdup_append(res, fallback);
+ } else {
+ bstr dir = mp_dirname(mpctx->filename);
+ if (!bstr_equals0(dir, "."))
+ res = talloc_asprintf_append(res, "%.*s", BSTR_P(dir));
+ }
+ break;
+ }
case 'p':
case 'P': {
char *t = mp_format_time(get_current_time(mpctx), fmt == 'P');