From 06117cbaab3e8bf347fa59fe194210cf627e553a Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 3 Sep 2005 13:35:55 +0200 Subject: [PATCH] Implemented option '--vfat'; replaced ':' with '.' in recording names --- CONTRIBUTORS | 1 + HISTORY | 6 ++ INSTALL | 3 +- recording.c | 152 +++++++++++++++++++++++++-------------------------- recording.h | 4 +- vdr.c | 11 +++- 6 files changed, 96 insertions(+), 81 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bfbc863a..4d7b64c0 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -910,6 +910,7 @@ Hermann Gausterer Peter Bieringer for reporting a problem with duplicate recordings with the same file name + for suggesting to implement the command line option '--vfat' Alexander Damhuis for reporting problems when deleting a timer that is currently recording diff --git a/HISTORY b/HISTORY index df5cb287..bbddc4e1 100644 --- a/HISTORY +++ b/HISTORY @@ -3783,3 +3783,9 @@ Video Disk Recorder Revision History the static function cRemote::CallPlugin(). - The SVDRP command PLUG now has a new option 'main' which can be used to initiate a call to the main menu function of a plugin (using part of a patch by Hardy Flor). +- The new command line option '--vfat' can be used to make VDR encode special + characters in recording file names, even if it wasn't compiled with VFAT=1 + (suggested by Peter Bieringer). The compile time option VFAT still exists and + creates a VDR that always behaves as if it were called with '--vfat'. +- Replaced the ':' delimiter between hour and minute in recording file names with + a '.' under Linux, too. Existing recordings with ':' as delimiter will still work. diff --git a/INSTALL b/INSTALL index 4ed92e49..540b45f2 100644 --- a/INSTALL +++ b/INSTALL @@ -71,7 +71,8 @@ time switch VFAT=1 -to the 'make' command. +to the 'make' command. Alternatively, you can call VDR with the command +line option '--vfat'. When running, the 'vdr' program writes status information into the system log file (/var/log/messages). You may want to watch these diff --git a/recording.c b/recording.c index f9c424cd..474c8ad0 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 1.111 2005/08/13 14:00:48 kls Exp $ + * $Id: recording.c 1.112 2005/09/03 13:16:57 kls Exp $ */ #include "recording.h" @@ -36,15 +36,8 @@ #define DATAFORMAT "%4d-%02d-%02d.%02d:%02d.%02d.%02d" RECEXT #define NAMEFORMAT "%s/%s/" DATAFORMAT */ -// start of implementation for brain dead systems #define DATAFORMAT "%4d-%02d-%02d.%02d%*c%02d.%02d.%02d" RECEXT -#ifdef VFAT -#define nameFORMAT "%4d-%02d-%02d.%02d.%02d.%02d.%02d" RECEXT -#else -#define nameFORMAT "%4d-%02d-%02d.%02d:%02d.%02d.%02d" RECEXT -#endif -#define NAMEFORMAT "%s/%s/" nameFORMAT -// end of implementation for brain dead systems +#define NAMEFORMAT "%s/%s/" "%4d-%02d-%02d.%02d.%02d.%02d.%02d" RECEXT #define RESUMEFILESUFFIX "/resume%s%s.vdr" #ifdef SUMMARYFALLBACK @@ -65,6 +58,8 @@ #define MAX_SUBTITLE_LENGTH 40 +bool VfatFileSystem = false; + void RemoveDeletedRecordings(void) { static time_t LastRemoveCheck = 0; @@ -297,79 +292,80 @@ static char *ExchangeChars(char *s, bool ToFileSystem) { char *p = s; while (*p) { -#ifdef VFAT - // The VFAT file system can't handle all characters, so we - // have to take extra efforts to encode/decode them: - if (ToFileSystem) { - switch (*p) { - // characters that can be used "as is": - case '!': - case '@': - case '$': - case '%': - case '&': - case '(': - case ')': - case '+': - case ',': - case '-': - case ';': - case '=': - case '0' ... '9': - case 'a' ... 'z': - case 'A' ... 'Z': - case 'ä': case 'Ä': - case 'ö': case 'Ö': - case 'ü': case 'Ü': - case 'ß': - break; - // characters that can be mapped to other characters: - case ' ': *p = '_'; break; - case '~': *p = '/'; break; - // characters that have to be encoded: - default: - if (*p != '.' || !*(p + 1) || *(p + 1) == '~') { // Windows can't handle '.' at the end of directory names - int l = p - s; - s = (char *)realloc(s, strlen(s) + 10); - p = s + l; - char buf[4]; - sprintf(buf, "#%02X", (unsigned char)*p); - memmove(p + 2, p, strlen(p) + 1); - strncpy(p, buf, 3); - p += 2; - } - } + if (VfatFileSystem) { + // The VFAT file system can't handle all characters, so we + // have to take extra efforts to encode/decode them: + if (ToFileSystem) { + switch (*p) { + // characters that can be used "as is": + case '!': + case '@': + case '$': + case '%': + case '&': + case '(': + case ')': + case '+': + case ',': + case '-': + case ';': + case '=': + case '0' ... '9': + case 'a' ... 'z': + case 'A' ... 'Z': + case 'ä': case 'Ä': + case 'ö': case 'Ö': + case 'ü': case 'Ü': + case 'ß': + break; + // characters that can be mapped to other characters: + case ' ': *p = '_'; break; + case '~': *p = '/'; break; + // characters that have to be encoded: + default: + if (*p != '.' || !*(p + 1) || *(p + 1) == '~') { // Windows can't handle '.' at the end of directory names + int l = p - s; + s = (char *)realloc(s, strlen(s) + 10); + p = s + l; + char buf[4]; + sprintf(buf, "#%02X", (unsigned char)*p); + memmove(p + 2, p, strlen(p) + 1); + strncpy(p, buf, 3); + p += 2; + } + } + } + else { + switch (*p) { + // mapped characters: + case '_': *p = ' '; break; + case '/': *p = '~'; break; + // encodes characters: + case '#': { + if (strlen(p) > 2) { + char buf[3]; + sprintf(buf, "%c%c", *(p + 1), *(p + 2)); + unsigned char c = strtol(buf, NULL, 16); + *p = c; + memmove(p + 1, p + 3, strlen(p) - 2); + } + } + break; + // backwards compatibility: + case '\x01': *p = '\''; break; + case '\x02': *p = '/'; break; + case '\x03': *p = ':'; break; + } + } } else { - switch (*p) { - // mapped characters: - case '_': *p = ' '; break; - case '/': *p = '~'; break; - // encodes characters: - case '#': { - if (strlen(p) > 2) { - char buf[3]; - sprintf(buf, "%c%c", *(p + 1), *(p + 2)); - unsigned char c = strtol(buf, NULL, 16); - *p = c; - memmove(p + 1, p + 3, strlen(p) - 2); - } - } + for (struct tCharExchange *ce = CharExchange; ce->a && ce->b; ce++) { + if (*p == (ToFileSystem ? ce->a : ce->b)) { + *p = ToFileSystem ? ce->b : ce->a; break; - // backwards compatibility: - case '\x01': *p = '\''; break; - case '\x02': *p = '/'; break; - case '\x03': *p = ':'; break; - } - } -#else - for (struct tCharExchange *ce = CharExchange; ce->a && ce->b; ce++) { - if (*p == (ToFileSystem ? ce->a : ce->b)) { - *p = ToFileSystem ? ce->b : ce->a; - break; + } } - } -#endif + } p++; } return s; diff --git a/recording.h b/recording.h index 05c34e28..567c6c41 100644 --- a/recording.h +++ b/recording.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.h 1.39 2005/08/13 14:09:50 kls Exp $ + * $Id: recording.h 1.40 2005/09/03 13:04:41 kls Exp $ */ #ifndef __RECORDING_H @@ -18,6 +18,8 @@ #include "timers.h" #include "tools.h" +extern bool VfatFileSystem; + void RemoveDeletedRecordings(void); void AssertFreeDiskSpace(int Priority = 0); ///< The special Priority value -1 means that we shall get rid of any diff --git a/vdr.c b/vdr.c index 8d86089f..4375ec77 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/vdr * - * $Id: vdr.c 1.214 2005/09/03 12:35:29 kls Exp $ + * $Id: vdr.c 1.215 2005/09/03 13:21:32 kls Exp $ */ #include @@ -131,6 +131,9 @@ int main(int argc, char *argv[]) #elif defined(REMOTE_RCU) RcuDevice = RCU_DEVICE; #endif +#if defined(VFAT) + VfatFileSystem = true; +#endif cPluginManager PluginManager(DEFAULTPLUGINDIR); int ExitCode = 0; @@ -154,6 +157,7 @@ int main(int argc, char *argv[]) { "shutdown", required_argument, NULL, 's' }, { "terminal", required_argument, NULL, 't' }, { "version", no_argument, NULL, 'V' }, + { "vfat", no_argument, NULL, 'v' | 0x100 }, { "video", required_argument, NULL, 'v' }, { "watchdog", required_argument, NULL, 'w' }, { NULL } @@ -246,6 +250,9 @@ int main(int argc, char *argv[]) break; case 'V': DisplayVersion = true; break; + case 'v' | 0x100: + VfatFileSystem = true; + break; case 'v': VideoDirectory = optarg; while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/') optarg[strlen(optarg) - 1] = 0; @@ -304,6 +311,8 @@ int main(int argc, char *argv[]) " -t TTY, --terminal=TTY controlling tty\n" " -v DIR, --video=DIR use DIR as video directory (default: %s)\n" " -V, --version print version information and exit\n" + " --vfat encode special characters in recording names to\n" + " avoid problems with VFAT file systems\n" " -w SEC, --watchdog=SEC activate the watchdog timer with a timeout of SEC\n" " seconds (default: %d); '0' disables the watchdog\n" "\n",