15 if (DirName && *DirName) {
18 const char *p = *s + l;
42 cCopyingThread(
const char *SourceName,
const char *ToFileName,
bool DeleteSource =
false);
50 deleteSource(DeleteSource),
55 const char *delim =
"/";
77 error =
"invalid target";
83 recname.
Truncate(strlen(*recname) - 1);
99 recname.
Truncate(strlen(*recname) - 1);
113 if (required < available) {
119 const int len = 1024 * 1024;
120 char *buffer =
MALLOC(
char, len);
129 if (strcmp(e->d_name,
".") && strcmp(e->d_name,
"..") && strcmp(e->d_name,
"lost+found")) {
135 if (!stat(*sourceFile, &sts) && S_ISREG(sts.st_mode)) {
141 if (!inputFile || !outputFile) {
148 r = inputFile->
Read(buffer, len);
150 w = outputFile->
Write(buffer, r);
153 }
while (
Running() && r > 0 && w > 0);
158 if (!
Running() || r < 0 || w < 0) {
175 error =
"copy failed";
182 recname.
Truncate(strlen(*recname) - 1);
190 error =
"insufficient free space";
225 if (strlen(*NewName)) {
240 if (Interrupted || Error) {
242 isyslog(
"file transfer has been interrupted");
244 esyslog(
"ERROR: '%s' during file transfer", Error);
struct dirent * Next(void)
cString NewVideoFileName(const char *FileName, const char *NewDirName)
ssize_t Write(const void *Data, size_t Size)
bool RemoveVideoFile(const char *FileName)
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
void DelByName(const char *FileName, bool RemoveRecording=true)
ssize_t Read(void *Data, size_t Size)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
static char * copiedVersionName
const char * VideoDirectory
cString & Truncate(int Index)
Truncate the string at the given Index (if Index is < 0 it is counted from the end of the string)...
void SetPriority(int Priority)
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner...
cRecording * GetByName(const char *FileName)
void UpdateByName(const char *FileName)
void bool Start(void)
Actually starts the thread.
bool Delete(void)
Changes the file name so that it will no longer be visible in the "Recordings" menu Returns false in ...
static cCopyingThread * copyingThread
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
void TouchUpdate(void)
Touches the '.update' file in the video directory, so that other instances of VDR that access the sam...
virtual ~cCopyingThread()
void SetIOPriority(int Priority)
static bool Start(cRecording *Recording, const char *NewName, bool CopyOnly=false)
bool Active(void)
Checks whether the thread is still alive.
static cString StripLastDirectory(const char *DirName)
static cUnbufferedFile * Create(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
const char * FileName(void) const
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
cCopyingThread(const char *SourceName, const char *ToFileName, bool DeleteSource=false)
void AddByName(const char *FileName, bool TriggerUpdate=true)