vdr 2.6.1
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
16class cVideoDirectory {
17private:
18 static cMutex mutex;
19 static cString name;
21 static cVideoDirectory *Current(void);
22public:
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
87class cVideoDiskUsage {
88private:
89 static int state;
90 static time_t lastChecked;
91 static int usedPercent;
92 static int freeMB;
93 static int freeMinutes;
94public:
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
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner,...
virtual int FreeMB(int *UsedMB=NULL)
Returns the total amount (in MB) of free disk space for recording.
Definition: videodir.c:55
static void Destroy(void)
static bool IsOnVideoDirectoryFileSystem(const char *FileName)
static cString name
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...
static const char * Name(void)
Definition: videodir.c:60
static cString PrefixVideoFileName(const char *FileName, char Prefix)
static bool MoveVideoFile(const char *FromName, const char *ToName)
virtual bool Contains(const char *Name)
Checks whether the directory Name is on the same file system as the video directory.
virtual bool Move(const char *FromName, const char *ToName)
Moves the directory FromName to the location ToName.
static cUnbufferedFile * OpenVideoFile(const char *FileName, int Flags)
static bool RenameVideoFile(const char *OldName, const char *NewName)
static int VideoDiskSpace(int *FreeMB=NULL, int *UsedMB=NULL)
virtual ~cVideoDirectory()
static bool RemoveVideoFile(const char *FileName)
static cVideoDirectory * Current(void)
virtual bool Rename(const char *OldName, const char *NewName)
Renames the directory OldName to NewName.
virtual bool Remove(const char *Name)
Removes the directory with the given Name and everything it contains.
virtual int FreeMB(int *UsedMB=NULL)
Returns the total amount (in MB) of free disk space for recording.
static const char * Name(void)
virtual void Cleanup(const char *IgnoreFiles[]=NULL)
Recursively removes all empty directories under the video directory.
static void RemoveEmptyVideoDirectories(const char *IgnoreFiles[]=NULL)
static bool VideoFileSpaceAvailable(int SizeMB)
static void SetName(const char *Name)
static cVideoDirectory * current
static void ForceCheck(void)
To avoid unnecessary load, the video disk usage is only actually checked every DISKSPACECHEK seconds.
Definition: videodir.h:101
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
static time_t lastChecked
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 bool HasChanged(int &State)
Returns true if the usage of the video disk space has changed since the last call to this function wi...
static int UsedPercent(void)
Returns the used space of the video disk in percent.
Definition: videodir.h:112