diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2012-04-23 09:07:55 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2012-04-23 09:07:55 +0200 |
commit | 3d32b07862aff8de213e999f27eaf9082696ec01 (patch) | |
tree | 89a8261b475654df3cce58b81743ecc451aab448 /videodir.c | |
parent | 09e58657a1abc2dcebf1761c5c2406f3b4a4345f (diff) | |
download | vdr-3d32b07862aff8de213e999f27eaf9082696ec01.tar.gz vdr-3d32b07862aff8de213e999f27eaf9082696ec01.tar.bz2 |
The disk usage is no longer automatically added to the title of the main and "Recordings" menus
Diffstat (limited to 'videodir.c')
-rw-r--r-- | videodir.c | 42 |
1 files changed, 41 insertions, 1 deletions
@@ -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")); +} |