From 3d32b07862aff8de213e999f27eaf9082696ec01 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 23 Apr 2012 09:07:55 +0200 Subject: The disk usage is no longer automatically added to the title of the main and "Recordings" menus --- videodir.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'videodir.c') diff --git a/videodir.c b/videodir.c index e61e3cbc..870b4cba 100644 --- a/videodir.c +++ b/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")); +} -- cgit v1.2.3