]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Issue 1625 - Option for Windows-compatible filenames * trim trailing spaces and dots
authorDamian Gołda <Damian.Golda@gmail.com>
Sun, 11 Jan 2015 13:20:34 +0000 (14:20 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 12 Jan 2015 08:51:23 +0000 (09:51 +0100)
docs/html/config_dvr.html
src/dvr/dvr_rec.c

index 82920b2429ab45d1a29cbc992b1ef96f1d1425dd..a0efaa2f2c7b42750c064633cacb8302cb12a3fd 100644 (file)
   <dd>If checked, whitespace characters (spaces and tabs) will be replaced with '-'.
   
   <dt>Use Windows-compatible filenames
-  <dd>If checked, special characters not supported by Windows like: <i>/ : \ < > | * ? ' "</i> will be replaced with '_'.
+  <dd>If checked:<br>
+      * special characters not supported by Windows like: <i>/ : \ < > | * ? ' "</i> will be replaced with '_'<br>
+      * trailing spaces ' ' and dots '.' will be removed
   
  </dl>
  Changes to any of these settings must be confirmed by pressing the 'Save configuration' button before taking effect.
index f669abee01edd1902dd0e04dfd8ad950985d5bde..e7c8a73e4e266c1adfd182165864040574a182cd 100644 (file)
@@ -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;
 }