From patchwork Tue Oct 4 17:26:58 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christoph Haubrich X-Patchwork-Id: 12054 Received: from postman4.arcor-online.net ([151.189.20.158] helo=postman.arcor.de) by www.linuxtv.org with esmtp (Exim 4.50) id 1EMqZQ-0007k7-Uk for vdr@linuxtv.org; Tue, 04 Oct 2005 19:27:16 +0200 Received: from merlin.local (p54AE89E8.dip0.t-ipconnect.de [84.174.137.232]) (authenticated bits=0) by postman.arcor.de (8.13.4/8.13.4) with ESMTP id j94HRE2w014225 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 4 Oct 2005 19:27:15 +0200 (MEST) Subject: Re: [vdr] Wanted: Filesize of recordings available in skins From: Christoph Haubrich To: "Klaus Schmidinger's VDR" In-Reply-To: References: Message-Id: <1128446818.3737.34.camel@merlin.local> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Tue, 04 Oct 2005 19:26:58 +0200 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2005 17:27:17 -0000 Status: O X-Status: X-Keywords: X-UID: 5315 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 diff -Nur vdr-1.3.32-org/i18n.c vdr-1.3.32/i18n.c --- vdr-1.3.32-org/i18n.c 2005-09-18 14:36:43.000000000 +0200 +++ vdr-1.3.32/i18n.c 2005-09-18 14:46:48.000000000 +0200 @@ -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 } }; diff -Nur vdr-1.3.32-org/menu.c vdr-1.3.32/menu.c --- vdr-1.3.32-org/menu.c 2005-09-18 14:36:43.000000000 +0200 +++ vdr-1.3.32/menu.c 2005-09-18 14:47:54.000000000 +0200 @@ -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)