From 028826b7df9b62abf46aa083cbecfea5a84a5aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Go=C5=82da?= Date: Sun, 11 Jan 2015 14:20:34 +0100 Subject: [PATCH] Issue 1625 - Option for Windows-compatible filenames * trim trailing spaces and dots --- docs/html/config_dvr.html | 4 +++- src/dvr/dvr_rec.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/html/config_dvr.html b/docs/html/config_dvr.html index 82920b24..a0efaa2f 100644 --- a/docs/html/config_dvr.html +++ b/docs/html/config_dvr.html @@ -186,7 +186,9 @@
If checked, whitespace characters (spaces and tabs) will be replaced with '-'.
Use Windows-compatible filenames -
If checked, special characters not supported by Windows like: / : \ < > | * ? ' " will be replaced with '_'. +
If checked:
+ * special characters not supported by Windows like: / : \ < > | * ? ' " will be replaced with '_'
+ * trailing spaces ' ' and dots '.' will be removed Changes to any of these settings must be confirmed by pressing the 'Save configuration' button before taking effect. diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index f669abee..e7c8a73e 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -151,7 +151,8 @@ cleanup_filename(char *s, dvr_config_t *cfg) if (s[0] == '.') s[0] = '_'; - for (i = 0, len = strlen(s); i < len; i++) { + int len2 = strlen(s); + for (i = 0; i < len2; i++) { if(s[i] == '/') s[i] = '-'; @@ -169,6 +170,18 @@ cleanup_filename(char *s, dvr_config_t *cfg) s[i] = '_'; } + if(cfg->dvr_windows_compatible_filenames) { + //trim trailing spaces and dots + for (i = len2 - 1; i >= 0; i--) { + if((s[i] == ' ') || (s[i] == '.')) { + s[i] = '\0'; + } + else { + break; + } + } + } + return s; }