66 if (strstr(FileName,
Name()) != FileName) {
76 dsyslog(
"renaming '%s' to '%s'", OldName, NewName);
77 if (rename(OldName, NewName) == -1) {
86 dsyslog(
"moving '%s' to '%s'", FromName, ToName);
88 if (rename(FromName, ToName) == -1) {
153 return (free + used) ? used * 100 / (free + used) : 0;
158 char PrefixedName[strlen(FileName) + 2];
160 const char *p = FileName + strlen(FileName);
162 while (p-- > FileName && n > 0) {
165 int l = p - FileName + 1;
166 strncpy(PrefixedName, FileName, l);
167 PrefixedName[l] = Prefix;
168 strcpy(PrefixedName + l + 1, p + 1);
188 #define DISKSPACECHEK 5 // seconds between disk space checks 189 #define MB_PER_MINUTE 25.75 // this is just an estimate! 202 if (FreeMB != freeMB) {
203 usedPercent = UsedPercent;
206 if (MBperMinute <= 0)
208 freeMinutes = int(
double(FreeMB) / MBperMinute);
211 lastChecked = time(NULL);
213 if (State != state) {
223 return cString::sprintf(
"%s %d%% - %2d:%02d %s",
tr(
"Disk"), usedPercent, freeMinutes / 60, freeMinutes % 60,
tr(
"free"));
static bool RenameVideoFile(const char *OldName, const char *NewName)
int TotalFileSizeMB(void)
virtual ~cVideoDirectory()
static cVideoDirectory * current
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
virtual bool Move(const char *FromName, const char *ToName)
Moves the directory FromName to the location ToName.
static cString sprintf(const char *fmt,...) __attribute__((format(printf
virtual bool Contains(const char *Name)
Checks whether the directory Name is on the same file system as the video directory.
static bool VideoFileSpaceAvailable(int SizeMB)
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner...
virtual bool Remove(const char *Name)
Removes the directory with the given Name and everything it contains.
static cUnbufferedFile * OpenVideoFile(const char *FileName, int Flags)
static cString PrefixVideoFileName(const char *FileName, char Prefix)
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)
static void Destroy(void)
static void RemoveEmptyVideoDirectories(const char *IgnoreFiles[]=NULL)
virtual bool Rename(const char *OldName, const char *NewName)
Renames the directory OldName to NewName.
static void SetName(const char *Name)
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...
virtual int FreeMB(int *UsedMB=NULL)
Returns the total amount (in MB) of free disk space for recording.
static cVideoDirectory * Current(void)
cRecordingsHandler RecordingsHandler
cRecordings DeletedRecordings
static int VideoDiskSpace(int *FreeMB=NULL, int *UsedMB=NULL)
static bool RemoveVideoFile(const char *FileName)
static bool MoveVideoFile(const char *FromName, const char *ToName)
cRecordings Recordings
Any access to Recordings that loops through the list of recordings needs to hold a thread lock on thi...
double MBperMinute(void)
Returns the average data rate (in MB/min) of all recordings, or -1 if this value is unknown...
static bool IsOnVideoDirectoryFileSystem(const char *FileName)
static cUnbufferedFile * Create(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
virtual void Cleanup(const char *IgnoreFiles[]=NULL)
Recursively removes all empty directories under the video directory.
static time_t lastChecked
bool Add(int Usage, const char *FileNameSrc, const char *FileNameDst=NULL)
Adds the given FileNameSrc to the recordings handler for (later) processing.