[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 2/3] lpt: Statistik nach dem Herunterladen anzeigen



+ lpt: Dateigroesse und benoetigte Zeit anzeigen, nachdem eine Datei
  heruntergeladen worden ist.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/pas/lpt/helpers.pas    |   11 +++++++++++
 src/modules/pas/lpt/lang/lang_en.c |    4 ++++
 src/modules/pas/lpt/lang/resstr.h  |    1 +
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/modules/pas/lpt/helpers.pas b/src/modules/pas/lpt/helpers.pas
index b9a4b76..b4783b9 100644
--- a/src/modules/pas/lpt/helpers.pas
+++ b/src/modules/pas/lpt/helpers.pas
@@ -22,6 +22,7 @@ resourcestring
     rsBytesReceivedPartial = '%d/%d Bytes empfangen';
 
     rsDownloading = 'Herunterladen von %s';
+    rsDownloadSummary = '%d %[0:Byte:Bytes] in %ds heruntergeladen';
     rsConnecting = 'Verbinde...';
     rsHTTPError = 'Fehler: HTTP-Statuscode';
 
@@ -110,16 +111,26 @@ begin
     end;
 end;
 
+function GetTickCount: Int64; cdecl; external name 'get_tick_count';
+
 function DownloadToTarArchive(url: String): TTarArchive;
 var
     f: File;
     httpc: HTTPRequest;
     tar: TTarArchive;
     i: integer;
+
+    start_time, end_time: Int64;
 begin
     DownloadToTarArchive := nil;
+
+    start_time := GetTickCount;
     httpc := StartDownload(url);
+    end_time := GetTickCount;
+
     if httpc <> nil then begin
+        WriteLn(FormatNum(rsDownloadSummary, [httpc.responseLength,
+            ((end_time - start_time) div 1000000)]));
         tar := TTarArchive.create(httpc.binaryResponseBody, httpc.responseLength);
         DownloadToTarArchive := tar;
     end;
diff --git a/src/modules/pas/lpt/lang/lang_en.c b/src/modules/pas/lpt/lang/lang_en.c
index 2a11663..327e837 100644
--- a/src/modules/pas/lpt/lang/lang_en.c
+++ b/src/modules/pas/lpt/lang/lang_en.c
@@ -47,6 +47,10 @@ static const struct tms_strings dict[] = {
     &RESSTR_HELPERS_RSDOWNLOADING,
     "Downloading %s",
 
+    // %d %[0:Byte:Bytes] in %ds heruntergeladen
+    &RESSTR_HELPERS_RSDOWNLOADSUMMARY,
+    "Downloaded %d %[0:byte:bytes] in %ds",
+
     // Verbinde...
     &RESSTR_HELPERS_RSCONNECTING,
     "Connecting...",
diff --git a/src/modules/pas/lpt/lang/resstr.h b/src/modules/pas/lpt/lang/resstr.h
index 707c725..4797955 100644
--- a/src/modules/pas/lpt/lang/resstr.h
+++ b/src/modules/pas/lpt/lang/resstr.h
@@ -32,6 +32,7 @@
 extern void* RESSTR_HELPERS_RSBYTESRECEIVED;
 extern void* RESSTR_HELPERS_RSBYTESRECEIVEDPARTIAL;
 extern void* RESSTR_HELPERS_RSDOWNLOADING;
+extern void* RESSTR_HELPERS_RSDOWNLOADSUMMARY;
 extern void* RESSTR_HELPERS_RSCONNECTING;
 extern void* RESSTR_HELPERS_RSHTTPERROR;
 extern void* RESSTR_P$LPT_RSUSAGE;
-- 
1.6.0.2