vdr  2.4.7
videodir.h
Go to the documentation of this file.
1 /*
2  * videodir.h: Functions to maintain the video directory
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: videodir.h 4.1 2015/08/10 13:21:29 kls Exp $
8  */
9 
10 #ifndef __VIDEODIR_H
11 #define __VIDEODIR_H
12 
13 #include <stdlib.h>
14 #include "tools.h"
15 
17 private:
18  static cMutex mutex;
19  static cString name;
21  static cVideoDirectory *Current(void);
22 public:
23  cVideoDirectory(void);
24  virtual ~cVideoDirectory();
25  virtual int FreeMB(int *UsedMB = NULL);
29  virtual bool Register(const char *FileName);
40  virtual bool Rename(const char *OldName, const char *NewName);
47  virtual bool Move(const char *FromName, const char *ToName);
53  virtual bool Remove(const char *Name);
58  virtual void Cleanup(const char *IgnoreFiles[] = NULL);
64  virtual bool Contains(const char *Name);
73  static const char *Name(void);
74  static void SetName(const char *Name);
75  static void Destroy(void);
76  static cUnbufferedFile *OpenVideoFile(const char *FileName, int Flags);
77  static bool RenameVideoFile(const char *OldName, const char *NewName);
78  static bool MoveVideoFile(const char *FromName, const char *ToName);
79  static bool RemoveVideoFile(const char *FileName);
80  static bool VideoFileSpaceAvailable(int SizeMB);
81  static int VideoDiskSpace(int *FreeMB = NULL, int *UsedMB = NULL); // returns the used disk space in percent
82  static cString PrefixVideoFileName(const char *FileName, char Prefix);
83  static void RemoveEmptyVideoDirectories(const char *IgnoreFiles[] = NULL);
84  static bool IsOnVideoDirectoryFileSystem(const char *FileName);
85  };
86 
88 private:
89  static int state;
90  static time_t lastChecked;
91  static int usedPercent;
92  static int freeMB;
93  static int freeMinutes;
94 public:
95  static bool HasChanged(int &State);
101  static void ForceCheck(void) { lastChecked = 0; }
106  static cString String(void);
112  static int UsedPercent(void) { return usedPercent; }
115  static int FreeMB(void) { return freeMB; }
118  static int FreeMinutes(void) { return freeMinutes; }
123  };
124 
125 #endif //__VIDEODIR_H
Definition: thread.h:67
Definition: tools.h:174
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner,...
Definition: tools.h:461
virtual int FreeMB(int *UsedMB=NULL)
Returns the total amount (in MB) of free disk space for recording.
Definition: videodir.c:55
virtual bool Contains(const char *Name)
Checks whether the directory Name is on the same file system as the video directory.
Definition: videodir.c:115
static cString PrefixVideoFileName(const char *FileName, char Prefix)
Definition: videodir.c:164
static void Destroy(void)
Definition: videodir.c:50
static void RemoveEmptyVideoDirectories(const char *IgnoreFiles[]=NULL)
Definition: videodir.c:184
static bool IsOnVideoDirectoryFileSystem(const char *FileName)
Definition: videodir.c:189
cVideoDirectory(void)
Definition: videodir.c:26
static cVideoDirectory * current
Definition: videodir.h:20
static const char * Name(void)
Definition: videodir.c:60
static cMutex mutex
Definition: videodir.h:18
static cUnbufferedFile * OpenVideoFile(const char *FileName, int Flags)
Definition: videodir.c:120
static bool VideoFileSpaceAvailable(int SizeMB)
Definition: videodir.c:142
static bool MoveVideoFile(const char *FromName, const char *ToName)
Definition: videodir.c:132
virtual bool Move(const char *FromName, const char *ToName)
Moves the directory FromName to the location ToName.
Definition: videodir.c:91
static int VideoDiskSpace(int *FreeMB=NULL, int *UsedMB=NULL)
Definition: videodir.c:147
virtual bool Rename(const char *OldName, const char *NewName)
Renames the directory OldName to NewName.
Definition: videodir.c:81
virtual void Cleanup(const char *IgnoreFiles[]=NULL)
Recursively removes all empty directories under the video directory.
Definition: videodir.c:110
virtual bool Register(const char *FileName)
By default VDR assumes that the video directory consists of one large volume, on which it can store i...
Definition: videodir.c:70
virtual bool Remove(const char *Name)
Removes the directory with the given Name and everything it contains.
Definition: videodir.c:105
virtual ~cVideoDirectory()
Definition: videodir.c:34
static void SetName(const char *Name)
Definition: videodir.c:65
static cVideoDirectory * Current(void)
Definition: videodir.c:41
static bool RenameVideoFile(const char *OldName, const char *NewName)
Definition: videodir.c:127
static bool RemoveVideoFile(const char *FileName)
Definition: videodir.c:137
static cString name
Definition: videodir.h:19
static void ForceCheck(void)
To avoid unnecessary load, the video disk usage is only actually checked every DISKSPACECHEK seconds.
Definition: videodir.h:101
static int state
Definition: videodir.h:89
static int freeMB
Definition: videodir.h:92
static int FreeMB(void)
Returns the amount of free space on the video disk in MB.
Definition: videodir.h:115
static int FreeMinutes(void)
Returns the number of minutes that can still be recorded on the video disk.
Definition: videodir.h:118
static int freeMinutes
Definition: videodir.h:93
static bool HasChanged(int &State)
Returns true if the usage of the video disk space has changed since the last call to this function wi...
Definition: videodir.c:205
static time_t lastChecked
Definition: videodir.h:90
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
Definition: videodir.c:229
static int usedPercent
Definition: videodir.h:91
static int UsedPercent(void)
Returns the used space of the video disk in percent.
Definition: videodir.h:112