mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
The disk usage is no longer automatically added to the title of the main and "Recordings" menus
This commit is contained in:
42
videodir.c
42
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.15 2008/02/16 13:00:03 kls Exp $
|
||||
* $Id: videodir.c 2.1 2012/04/22 15:03:10 kls Exp $
|
||||
*/
|
||||
|
||||
#include "videodir.h"
|
||||
@@ -241,3 +241,43 @@ bool IsOnVideoDirectoryFileSystem(const char *FileName)
|
||||
} while (Dir.Next());
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- cVideoDiskUsage -------------------------------------------------------
|
||||
|
||||
#define DISKSPACECHEK 5 // seconds between disk space checks
|
||||
#define MB_PER_MINUTE 25.75 // this is just an estimate!
|
||||
|
||||
int cVideoDiskUsage::state = 0;
|
||||
time_t cVideoDiskUsage::lastChecked = 0;
|
||||
int cVideoDiskUsage::usedPercent = 0;
|
||||
int cVideoDiskUsage::freeMB = 0;
|
||||
int cVideoDiskUsage::freeMinutes = 0;
|
||||
|
||||
bool cVideoDiskUsage::HasChanged(int &State)
|
||||
{
|
||||
if (time(NULL) - lastChecked > DISKSPACECHEK) {
|
||||
int FreeMB;
|
||||
int UsedPercent = VideoDiskSpace(&FreeMB);
|
||||
if (FreeMB != freeMB) {
|
||||
usedPercent = UsedPercent;
|
||||
freeMB = FreeMB;
|
||||
int MBperMinute = Recordings.MBperMinute();
|
||||
if (MBperMinute <= 0)
|
||||
MBperMinute = MB_PER_MINUTE;
|
||||
freeMinutes = int(double(FreeMB) / MBperMinute);
|
||||
state++;
|
||||
}
|
||||
lastChecked = time(NULL);
|
||||
}
|
||||
if (State != state) {
|
||||
State = state;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
cString cVideoDiskUsage::String(void)
|
||||
{
|
||||
HasChanged(state);
|
||||
return cString::sprintf("%s %d%% - %2d:%02d %s", tr("Disk"), usedPercent, freeMinutes / 60, freeMinutes % 60, tr("free"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user