diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-10-31 13:14:26 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-10-31 13:14:26 +0100 |
commit | 697261c981fa877b94661d310c07b216ca708f4f (patch) | |
tree | cd24930cf7529657301f8d886dc510bdc594c989 /videodir.c | |
parent | 998e3bd2c7d19485d001f1531d93fda2e92edb03 (diff) | |
download | vdr-697261c981fa877b94661d310c07b216ca708f4f.tar.gz vdr-697261c981fa877b94661d310c07b216ca708f4f.tar.bz2 |
The new class cUnbufferedFile is used for the recording files to avoid thrashing the file system cache1.3.35
Diffstat (limited to 'videodir.c')
-rw-r--r-- | videodir.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -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) |