diff options
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/recording.c b/recording.c index 5a703db..7ba93b3 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.92 2004/11/01 14:04:47 kls Exp $ + * $Id: recording.c 1.94 2004/12/26 11:55:24 kls Exp $ */ #include "recording.h" @@ -157,7 +157,7 @@ cResumeFile::cResumeFile(const char *FileName) fileName = MALLOC(char, strlen(FileName) + strlen(RESUMEFILESUFFIX) + 1); if (fileName) { strcpy(fileName, FileName); - sprintf(fileName + strlen(fileName), RESUMEFILESUFFIX, Setup.ResumeID ? "." : "", Setup.ResumeID ? itoa(Setup.ResumeID) : ""); + sprintf(fileName + strlen(fileName), RESUMEFILESUFFIX, Setup.ResumeID ? "." : "", Setup.ResumeID ? *itoa(Setup.ResumeID) : ""); } else esyslog("ERROR: can't allocate memory for resume file name"); @@ -541,8 +541,8 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) cons const char *cRecording::PrefixFileName(char Prefix) { - const char *p = PrefixVideoFileName(FileName(), Prefix); - if (p) { + cString p = PrefixVideoFileName(FileName(), Prefix); + if (*p) { free(fileName); fileName = strdup(p); return fileName; @@ -628,42 +628,39 @@ cRecordings::cRecordings(bool Deleted) void cRecordings::ScanVideoDir(const char *DirName) { - DIR *d = opendir(DirName); - if (d) { - struct dirent *e; - while ((e = readdir(d)) != NULL) { - if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) { - char *buffer; - asprintf(&buffer, "%s/%s", DirName, e->d_name); - struct stat st; - if (stat(buffer, &st) == 0) { - if (S_ISLNK(st.st_mode)) { + cReadDir d(DirName); + struct dirent *e; + while ((e = d.Next()) != NULL) { + if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) { + char *buffer; + asprintf(&buffer, "%s/%s", DirName, e->d_name); + struct stat st; + if (stat(buffer, &st) == 0) { + if (S_ISLNK(st.st_mode)) { + free(buffer); + buffer = ReadLink(buffer); + if (!buffer) + continue; + if (stat(buffer, &st) != 0) { free(buffer); - buffer = ReadLink(buffer); - if (!buffer) - continue; - if (stat(buffer, &st) != 0) { - free(buffer); - continue; - } + continue; } - if (S_ISDIR(st.st_mode)) { - if (endswith(buffer, deleted ? DELEXT : RECEXT)) { - cRecording *r = new cRecording(buffer); - if (r->Name()) - Add(r); - else - delete r; - } + } + if (S_ISDIR(st.st_mode)) { + if (endswith(buffer, deleted ? DELEXT : RECEXT)) { + cRecording *r = new cRecording(buffer); + if (r->Name()) + Add(r); else - ScanVideoDir(buffer); + delete r; } + else + ScanVideoDir(buffer); } - free(buffer); } + free(buffer); } - closedir(d); - } + } } bool cRecordings::NeedsUpdate(void) @@ -707,8 +704,6 @@ void cRecordings::DelByName(const char *FileName) // --- cMark ----------------------------------------------------------------- -char *cMark::buffer = NULL; - cMark::cMark(int Position, const char *Comment) { position = Position; @@ -720,10 +715,10 @@ cMark::~cMark() free(comment); } -const char *cMark::ToText(void) +cString cMark::ToText(void) { - free(buffer); - asprintf(&buffer, "%s%s%s\n", IndexToHMSF(position, true), comment ? " " : "", comment ? comment : ""); + char *buffer; + asprintf(&buffer, "%s%s%s\n", *IndexToHMSF(position, true), comment ? " " : "", comment ? comment : ""); return buffer; } @@ -750,8 +745,7 @@ bool cMark::Save(FILE *f) bool cMarks::Load(const char *RecordingFileName) { - const char *MarksFile = AddDirectory(RecordingFileName, MARKSFILESUFFIX); - if (cConfig<cMark>::Load(MarksFile)) { + if (cConfig<cMark>::Load(AddDirectory(RecordingFileName, MARKSFILESUFFIX))) { Sort(); return true; } @@ -815,7 +809,7 @@ void cRecordingUserCommand::InvokeCommand(const char *State, const char *Recordi { if (command) { char *cmd; - asprintf(&cmd, "%s %s \"%s\"", command, State, strescape(RecordingFileName, "\"$")); + asprintf(&cmd, "%s %s \"%s\"", command, State, *strescape(RecordingFileName, "\"$")); isyslog("executing '%s'", cmd); SystemExec(cmd); free(cmd); @@ -1156,9 +1150,9 @@ int cFileName::NextFile(void) // --- Index stuff ----------------------------------------------------------- -const char *IndexToHMSF(int Index, bool WithFrame) +cString IndexToHMSF(int Index, bool WithFrame) { - static char buffer[16]; + char buffer[16]; int f = (Index % FRAMESPERSEC) + 1; int s = (Index / FRAMESPERSEC); int m = s / 60 % 60; |