From: Damian Gołda Date: Sun, 11 Jan 2015 13:20:34 +0000 (+0100) Subject: Issue 1625 - Option for Windows-compatible filenames * trim trailing spaces and dots X-Git-Tag: v4.1~502 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=028826b7df9b62abf46aa083cbecfea5a84a5aa2;p=thirdparty%2Ftvheadend.git Issue 1625 - Option for Windows-compatible filenames * trim trailing spaces and dots --- diff --git a/docs/html/config_dvr.html b/docs/html/config_dvr.html index 82920b242..a0efaa2f2 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 f669abee0..e7c8a73e4 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; }