mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
The new class cUnbufferedFile is used for the recording files to avoid thrashing the file system cache
This commit is contained in:
21
videodir.c
21
videodir.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: videodir.c 1.12 2005/08/06 09:53:21 kls Exp $
|
||||
* $Id: videodir.c 1.13 2005/10/31 12:07:41 kls Exp $
|
||||
*/
|
||||
|
||||
#include "videodir.h"
|
||||
@@ -102,7 +102,7 @@ const char *cVideoDirectory::Adjust(const char *FileName)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OpenVideoFile(const char *FileName, int Flags)
|
||||
cUnbufferedFile *OpenVideoFile(const char *FileName, int Flags)
|
||||
{
|
||||
const char *ActualFileName = FileName;
|
||||
|
||||
@@ -110,7 +110,7 @@ int OpenVideoFile(const char *FileName, int Flags)
|
||||
if (strstr(FileName, VideoDirectory) != FileName) {
|
||||
esyslog("ERROR: %s not in %s", FileName, VideoDirectory);
|
||||
errno = ENOENT; // must set 'errno' - any ideas for a better value?
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
// Are we going to create a new file?
|
||||
if ((Flags & O_CREAT) != 0) {
|
||||
@@ -128,25 +128,26 @@ int OpenVideoFile(const char *FileName, int Flags)
|
||||
if (Dir.Stored()) {
|
||||
ActualFileName = Dir.Adjust(FileName);
|
||||
if (!MakeDirs(ActualFileName, false))
|
||||
return -1; // errno has been set by MakeDirs()
|
||||
return NULL; // errno has been set by MakeDirs()
|
||||
if (symlink(ActualFileName, FileName) < 0) {
|
||||
LOG_ERROR_STR(FileName);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ActualFileName = strdup(ActualFileName); // must survive Dir!
|
||||
}
|
||||
}
|
||||
}
|
||||
int Result = open(ActualFileName, Flags, DEFFILEMODE);
|
||||
cUnbufferedFile *File = cUnbufferedFile::Create(ActualFileName, Flags, DEFFILEMODE);
|
||||
if (ActualFileName != FileName)
|
||||
free((char *)ActualFileName);
|
||||
return Result;
|
||||
return File;
|
||||
}
|
||||
|
||||
int CloseVideoFile(int FileHandle)
|
||||
int CloseVideoFile(cUnbufferedFile *File)
|
||||
{
|
||||
// just in case we ever decide to do something special when closing the file!
|
||||
return close(FileHandle);
|
||||
int Result = File->Close();
|
||||
delete File;
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool RenameVideoFile(const char *OldName, const char *NewName)
|
||||
|
||||
Reference in New Issue
Block a user