summaryrefslogtreecommitdiff
path: root/videodir.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-04-23 09:07:55 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2012-04-23 09:07:55 +0200
commit3d32b07862aff8de213e999f27eaf9082696ec01 (patch)
tree89a8261b475654df3cce58b81743ecc451aab448 /videodir.c
parent09e58657a1abc2dcebf1761c5c2406f3b4a4345f (diff)
downloadvdr-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.c42
1 files changed, 41 insertions, 1 deletions
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"));
+}