Public access to cRecording::fileSizeMB

Message ID 444250EC.3010502@gmx.de
State New
Headers

Commit Message

Udo Richter April 16, 2006, 2:13 p.m. UTC
  Hi Klaus,

The attached patch provides public access to cRecording::fileSizeMB by 
adding a function cRecording::FileSizeMB(). The size is calculated if it 
is still unknown.
Please consider adding the patch to VDR. The patch shouldn't have any 
negative side effects and might be useful to others.

Cheers,

Udo
  

Comments

Klaus Schmidinger April 17, 2006, 8:41 a.m. UTC | #1
Udo Richter wrote:
> Hi Klaus,
> 
> The attached patch provides public access to cRecording::fileSizeMB by 
> adding a function cRecording::FileSizeMB(). The size is calculated if it 
> is still unknown.
> Please consider adding the patch to VDR. The patch shouldn't have any 
> negative side effects and might be useful to others.
> 
> Cheers,
> 
> Udo

You do realize that this will only work reliably for recordings
that have already been finished, right? An ongoing recording will
only tell you its size at the moment you call the function, and
will keep telling that size later on (until the next restart, or
until the /video/.update file has been touched and the list of
recordings has been refreshed). BTW: that's the reason why I did
not make this information public in the first place ;-)

Klaus

> ------------------------------------------------------------------------
> 
> --- vdr-1.3.46-orig/recording.h	2006-04-16 15:35:32.341839992 +0200
> +++ vdr-1.3.46/recording.h	2006-04-16 15:35:36.436217552 +0200
> @@ -87,6 +87,7 @@
>    const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1) const;
>    const cRecordingInfo *Info(void) const { return info; }
>    const char *PrefixFileName(char Prefix);
> +  int FileSizeMB();
>    int HierarchyLevels(void) const;
>    void ResetResume(void) const;
>    bool IsNew(void) const { return GetResume() <= 0; }
> --- vdr-1.3.46-orig/recording.c	2006-04-16 15:35:28.444432488 +0200
> +++ vdr-1.3.46/recording.c	2006-04-16 15:35:40.708568056 +0200
> @@ -762,6 +762,13 @@
>    return NULL;
>  }
>  
> +int cRecording::FileSizeMB()
> +{
> +  if (fileSizeMB < 0)
> +     fileSizeMB = DirSizeMB(FileName());
> +  return fileSizeMB;
> +}
> +
>  int cRecording::HierarchyLevels(void) const
>  {
>    const char *s = name;
  
Udo Richter April 17, 2006, 2:22 p.m. UTC | #2
Klaus Schmidinger wrote:
> You do realize that this will only work reliably for recordings
> that have already been finished, right? 

Hmmm, good point. I'll have to think about that.

Cheers,

Udo
  

Patch

--- vdr-1.3.46-orig/recording.h	2006-04-16 15:35:32.341839992 +0200
+++ vdr-1.3.46/recording.h	2006-04-16 15:35:36.436217552 +0200
@@ -87,6 +87,7 @@ 
   const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1) const;
   const cRecordingInfo *Info(void) const { return info; }
   const char *PrefixFileName(char Prefix);
+  int FileSizeMB();
   int HierarchyLevels(void) const;
   void ResetResume(void) const;
   bool IsNew(void) const { return GetResume() <= 0; }
--- vdr-1.3.46-orig/recording.c	2006-04-16 15:35:28.444432488 +0200
+++ vdr-1.3.46/recording.c	2006-04-16 15:35:40.708568056 +0200
@@ -762,6 +762,13 @@ 
   return NULL;
 }
 
+int cRecording::FileSizeMB()
+{
+  if (fileSizeMB < 0)
+     fileSizeMB = DirSizeMB(FileName());
+  return fileSizeMB;
+}
+
 int cRecording::HierarchyLevels(void) const
 {
   const char *s = name;