[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH] + lpt: Download() kann jetzt mit lokalen URI umgehen
---
trunk/src/modules/pas/lpt/lpt.pas | 59 ++++++++++++++++++++-----------------
1 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/trunk/src/modules/pas/lpt/lpt.pas b/trunk/src/modules/pas/lpt/lpt.pas
index 56d8b09..e8668cb 100644
--- a/trunk/src/modules/pas/lpt/lpt.pas
+++ b/trunk/src/modules/pas/lpt/lpt.pas
@@ -81,37 +81,42 @@ var
f: File;
httpc: HTTPRequest;
tar: TTarArchive;
+ i: integer;
begin
Download := false;
- try
- httpc := HTTPRequest.create(url);
- httpc.setRequestHeader('Pragma', 'no-cache');
- httpc.setRequestHeader('Cache-Control', 'no-cache');
- WriteLn('Herunterladen von ', url);
- Write('Verbinde...');
- httpc.onReadTick := @DrawProgress;
- httpc.get;
- WriteLn;
+ if Pos(url, 'http') > 0 then begin
+ try
+ httpc := HTTPRequest.create(url);
+ httpc.setRequestHeader('Pragma', 'no-cache');
+ httpc.setRequestHeader('Cache-Control', 'no-cache');
+ WriteLn('Herunterladen von ', url);
+ Write('Verbinde...');
+ httpc.onReadTick := @DrawProgress;
+ httpc.get;
+ WriteLn;
+
+ if httpc.statusCode <> 200 then begin
+ WriteLn('Fehler: HTTP-Statuscode ', httpc.statusCode);
+ end else if do_untar then begin
+ tar := TTarArchive.create(httpc.binaryResponseBody, httpc.responseLength);
+ Untar(tar);
+ Download := true;
+ end else begin
+ Assign(f, filename);
+ Rewrite(f, httpc.responseLength);
+ BlockWrite(f, httpc.binaryResponseBody^, 1);
+ Close(f);
+ Download := true;
+ end;
- if httpc.statusCode <> 200 then begin
- WriteLn('Fehler: HTTP-Statuscode ', httpc.statusCode);
- end else if do_untar then begin
- tar := TTarArchive.create(httpc.binaryResponseBody, httpc.responseLength);
- Untar(tar);
- Download := true;
- end else begin
- Assign(f, filename);
- Rewrite(f, httpc.responseLength);
- BlockWrite(f, httpc.binaryResponseBody^, 1);
- Close(f);
- Download := true;
+ httpc.done;
+ except
+ on e: Exception do WriteLn('EXCEPTION: ', e.message);
end;
-
- httpc.done;
- except
- on e: Exception do WriteLn('EXCEPTION: ', e.message);
+ end else begin
+ Untar(url);
+ Download := true;
end;
-
end;
procedure PrintUsage;
--
1.5.6.3