From ef0aba26bd3c9ca59fb4c0c451db78031a2d180d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 16 Jun 2001 10:36:13 +0200 Subject: [PATCH] VFAT switch exchanges ':' in recording names; modified exchanging characters --- HISTORY | 4 +++- recording.c | 36 +++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/HISTORY b/HISTORY index 5d0d94be..8843f991 100644 --- a/HISTORY +++ b/HISTORY @@ -506,7 +506,7 @@ Video Disk Recorder Revision History - Fixed removing recordings with Lifetime = 99. - Improved channel switching. -2001-06-15: Version 0.82 +2001-06-16: Version 0.82 - Increased timeout until reporting "broken video data stream" when recording. - Modified method of turning off PIDs when switching channel. @@ -528,3 +528,5 @@ Video Disk Recorder Revision History to multiplex smoothly with the video data. - Fixed a bug in the editing mechanism (didn't work with recordings that consist of more than one data file). +- The compile time switch VFAT has been fixed to recognize the ':' character + in recording names, too. diff --git a/recording.c b/recording.c index 6b35ef29..ddca1a4b 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.31 2001/06/12 15:31:32 kls Exp $ + * $Id: recording.c 1.32 2001/06/16 10:33:20 kls Exp $ */ #define _GNU_SOURCE @@ -177,18 +177,31 @@ void cResumeFile::Delete(void) // --- cRecording ------------------------------------------------------------ +struct tCharExchange { char a; char b; }; +tCharExchange CharExchange[] = { + { ' ', '_' }, + { '\'', '\x01' }, + { '/', '\x02' }, +#ifdef VFAT + { ':', '\x03' }, +#endif + { 0, 0 } + }; + +char *ExchangeChars(char *s, bool ToFileSystem) +{ + for (struct tCharExchange *ce = CharExchange; ce->a && ce->b; ce++) + strreplace(s, ToFileSystem ? ce->a : ce->b, ToFileSystem ? ce->b : ce->a); + return s; +} + cRecording::cRecording(cTimer *Timer) { titleBuffer = NULL; fileName = NULL; name = strdup(Timer->file); // substitute characters that would cause problems in file names: - for (char *p = name; *p; p++) { - switch (*p) { - case '\n': *p = ' '; break; - case '/': *p = '-'; break; - } - } + strreplace(name, '\n', ' '); summary = Timer->summary ? strdup(Timer->summary) : NULL; if (summary) strreplace(summary, '|', '\n'); @@ -218,8 +231,7 @@ cRecording::cRecording(const char *FileName) name = new char[p - FileName + 1]; strncpy(name, FileName, p - FileName); name[p - FileName] = 0; - strreplace(name, '_', ' '); - strreplace(name, '\x01', '\''); + ExchangeChars(name, false); } // read an optional summary file: char *SummaryFileName = NULL; @@ -269,11 +281,9 @@ const char *cRecording::FileName(void) { if (!fileName) { struct tm *t = localtime(&start); + ExchangeChars(name, true); asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime); - if (fileName) { - strreplace(fileName, ' ', '_'); - strreplace(fileName, '\'', '\x01'); - } + ExchangeChars(name, false); } return fileName; }