Wanted: Filesize of recordings available in skins
Commit Message
Am Do, 2005-09-29 um 19.36 schrieb Christoph Hermanns:
> 1. Is this size information already available for a plugin ?
> If not, i would highly welcome that this size information
> can be accessed from a plugin.
>
Hi,
some days ago I wrote some lines to display the size of a recording. It
requires Rolf Ahrenberg's enAIO-2.6-Patch (actually the rename-patch
which is included in enAIO but I didn't try that) and I tested it with
vdr 1.3.32 and 1.3.34.
It displays an additional line in the rename menu with the size in human
readable format (that is "GB" in most cases).
@Rolf: would you like to include it in your enAIO-Patch?
regards
Christoph
Comments
On Tue, 4 Oct 2005, Christoph Haubrich wrote:
> @Rolf: would you like to include it in your enAIO-Patch?
No, sorry. The recording length patch provides already the file
size and you can always use the calc-plugin to calculate the size
in megabytes instead of minutes displayed on the OSD.
BTW. Frank might include it into his BigPatch that contains all
non-essential patches/addons :)
BR,
--
rofa
@@ -5690,6 +5690,28 @@
"",//TODO
"",//TODO
},
+ { "Size",
+ "Größe",
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ "",//TODO
+ },
+
{ NULL }
};
@@ -1611,6 +1611,46 @@
Add(new cMenuEditRecPathItem(tr("Path"), path, sizeof(path) ));
Add(new cMenuEditIntItem(tr("Priority"), &priority, 0, MAXPRIORITY ));
Add(new cMenuEditIntItem(tr("Lifetime"), &lifetime, 0, MAXLIFETIME ));
+
+ long long llSize=0;
+ double dSize=0.0;
+ char *buffer = NULL;
+ DIR *dir=opendir(recording->FileName());
+ if (dir) {
+ struct dirent *entry;
+ struct stat fileinfo;
+ while ( NULL != (entry = readdir(dir))) {
+ asprintf (&buffer, "%s/%s", recording->FileName(), entry->d_name);
+ if (stat(buffer, &fileinfo) == 0) {
+ llSize += (long long)fileinfo.st_size;
+ }
+ else
+ {
+ isyslog("couldn't stat '%s': %s", buffer, strerror(errno));
+ }
+ free(buffer);
+ }
+ closedir(dir);
+ } else {
+ esyslog("Error opening directory \"%s\": %s", recording->FileName(), strerror(errno));
+ }
+
+ const char * const Units[5] = {"Bytes", "kB", "MB", "GB", "TB"};
+ int Unit = 0;
+ dSize = llSize;
+ while (dSize >= 1024.0)
+ {
+ dSize /= 1024.0;
+ Unit++;
+ }
+
+ asprintf (&buffer, "%s:\t%.2f %s", tr("Size"), dSize, Units[Unit]);
+
+ cOsdItem *item;
+ item = new cOsdItem(buffer);
+ item->SetSelectable(false);
+ Add(item);
+ free(buffer);
}
eOSState cMenuRenameRecording::ProcessKey(eKeys Key)