summaryrefslogtreecommitdiff
path: root/videodir.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-01-27 13:11:23 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-01-27 13:11:23 +0100
commit28e54bc648502820202ea44f6a990c9502f901f7 (patch)
tree436b3e56eb28e8c13002e97c511c11234c55f0b4 /videodir.c
parent53c5499a0b93cd1cb47394381c4262f01b6c0c00 (diff)
downloadvdr-28e54bc648502820202ea44f6a990c9502f901f7.tar.gz
vdr-28e54bc648502820202ea44f6a990c9502f901f7.tar.bz2
The 'Main' menu now displays the used disk space in the title
Diffstat (limited to 'videodir.c')
-rw-r--r--videodir.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/videodir.c b/videodir.c
index d9d3f852..dbb1bd19 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.6 2001/09/02 14:55:15 kls Exp $
+ * $Id: videodir.c 1.7 2002/01/27 12:37:26 kls Exp $
*/
#include "videodir.h"
@@ -27,7 +27,7 @@ private:
public:
cVideoDirectory(void);
~cVideoDirectory();
- uint FreeMB(void);
+ int FreeMB(int *UsedMB = NULL);
const char *Name(void) { return name ? name : VideoDirectory; }
const char *Stored(void) { return stored; }
int Length(void) { return length; }
@@ -53,9 +53,9 @@ cVideoDirectory::~cVideoDirectory()
delete adjusted;
}
-uint cVideoDirectory::FreeMB(void)
+int cVideoDirectory::FreeMB(int *UsedMB)
{
- return FreeDiskSpaceMB(name ? name : VideoDirectory);
+ return FreeDiskSpaceMB(name ? name : VideoDirectory, UsedMB);
}
bool cVideoDirectory::Next(void)
@@ -117,9 +117,9 @@ int OpenVideoFile(const char *FileName, int Flags)
cVideoDirectory Dir;
if (Dir.IsDistributed()) {
// Find the directory with the most free space:
- uint MaxFree = Dir.FreeMB();
+ int MaxFree = Dir.FreeMB();
while (Dir.Next()) {
- uint Free = FreeDiskSpaceMB(Dir.Name());
+ int Free = FreeDiskSpaceMB(Dir.Name());
if (Free > MaxFree) {
Dir.Store();
MaxFree = Free;
@@ -166,7 +166,7 @@ bool RemoveVideoFile(const char *FileName)
return RemoveFileOrDir(FileName, true);
}
-bool VideoFileSpaceAvailable(unsigned int SizeMB)
+bool VideoFileSpaceAvailable(int SizeMB)
{
cVideoDirectory Dir;
if (Dir.IsDistributed()) {
@@ -181,6 +181,22 @@ bool VideoFileSpaceAvailable(unsigned int SizeMB)
return Dir.FreeMB() >= SizeMB;
}
+int VideoDiskSpace(int *FreeMB, int *UsedMB)
+{
+ int free = 0, used = 0;
+ cVideoDirectory Dir;
+ do {
+ int u;
+ free += Dir.FreeMB(&u);
+ used += u;
+ } while (Dir.Next());
+ if (FreeMB)
+ *FreeMB = free;
+ if (UsedMB)
+ *UsedMB = used;
+ return (free + used) ? used * 100 / (free + used) : 0;
+}
+
const char *PrefixVideoFileName(const char *FileName, char Prefix)
{
static char *PrefixedName = NULL;