* Added OCurl based downloader

git-svn-id: trunk@5212 -
This commit is contained in:
michael 2006-11-03 20:48:52 +00:00
parent 202191e2cf
commit 6f4201bcfc
5 changed files with 100 additions and 2 deletions

1
.gitattributes vendored
View File

@ -7790,6 +7790,7 @@ utils/fppkg/pkgdownload.pp svneol=native#text/plain
utils/fppkg/pkghandler.pp svneol=native#text/plain
utils/fppkg/pkgmessages.pp svneol=native#text/plain
utils/fppkg/pkgmkconv.pp svneol=native#text/plain
utils/fppkg/pkgocurl.pp svneol=native#text/plain
utils/fppkg/pkgropts.pp svneol=native#text/plain
utils/fppkg/pkgsynapse.pp svneol=native#text/plain
utils/fppkg/pkgwget.pp svneol=native#text/plain

View File

@ -22,6 +22,10 @@ create a manifest file (in XML) to import in a repository.
All packager functionality will be implemented in units so
these units can be used in command-line and GUI package managers.
All packager command handling is implemented in descendents fom
TPackageHandler (pkghandler.pp). All messages emitted by these
handlers are in pkgmessages.
Units:
-----
@ -43,6 +47,25 @@ rep2xml
test program for the fprepos unit.
reptest
creates some test packages for use in the rep2xml test program.
fppkg
the package manager application
fpmkconv
Makefile.fpc to fpmake converter.
pkgmessages
the messages used in pkghandler and below.
pkghandler
the base for all fppkg command handlers
pkgdownload
a base implementation for download functionality in fppkg
pkgwget
a downloader based on spawning wget.
pkgsynapse
a downloader based on Synapse. Do not put in makefile, as Synapse is
not distributed by default with FPC.
pkgocurl
a downloader based on CurlPas (object version). Do not put in makefile,
as CurlPas is not distributed with FPC.
Options supported in packager config file:
------------------------------------------

View File

@ -105,7 +105,7 @@
<Filename Value="pkgdownload.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pkgdownload"/>
<CursorPos X="1" Y="94"/>
<CursorPos X="34" Y="64"/>
<TopLine Value="59"/>
<EditorIndex Value="3"/>
<UsageCount Value="20"/>

View File

@ -17,7 +17,10 @@ Resourcestring
SErrUnknownProtocol = 'Unknown download protocol: "%s"';
SErrNoSuchFile = 'File "%s" does not exist.';
SErrWGetDownloadFailed = 'Download failed: wget reported exit status %d.';
SErrHTTPGetFailed = 'HTTP Download failed.';
SErrLoginFailed = 'FTP LOGIN command failed.';
SErrCWDFailed = 'FTP CWD "%s" command failed.';
SErrGETFailed = 'FTP GET "%s" command failed.';
SLogGeneratingFPMake = 'Generating fpmake.pp';
SLogCompilingFPMake = 'Compiling fpmake.pp: ';
SLogRunningFPMake = 'Running fpmake';

71
utils/fppkg/pkgocurl.pp Normal file
View File

@ -0,0 +1,71 @@
{$mode objfpc}
{$h+}
unit pkgoCurl;
interface
uses Classes,pkgdownload;
Type
TOCurlDownloader = Class(TBasePackageDownloader)
Private
FCurl : String;
Protected
Procedure OCurlDownload(Const URL : String; Dest : TStream); virtual;
Procedure FTPDownload(Const URL : String; Dest : TStream); override;
Procedure HTTPDownload(Const URL : String; Dest : TStream); override;
Public
Property Curl : String Read FCurl Write FCurl;
end;
implementation
uses sysutils,curlobj,pkgmessages;
Procedure TOCurlDownloader.OCurlDownload(Const URL : String; Dest : TStream);
Var
ACurl : TCurl;
FN : String;
F : TFileStream;
begin
FN:=GetTempFileName();
Try
ACurl:=TCurl.Create(Nil);
Try
ACurl.URL:=URL;
ACurl.OutputFile:=FN;
ACurl.NoProgress:=True;
ACurl.Verbose:=False;
ACurl.FollowLocation:=True;
If Not ACurl.Perform then
Error(ACurl.ErrorString);
Finally
ACurl.Free;
end;
F:=TFileStream.Create(FN,fmOpenRead);
Try
Dest.CopyFrom(F,0);
Finally
F.Free;
end;
Finally
If FileExists(FN) then
DeleteFile(FN);
end;
end;
Procedure TOCurlDownloader.FTPDownload(Const URL : String; Dest : TStream);
begin
OCurlDownload(URL,Dest);
end;
Procedure TOCurlDownloader.HTTPDownload(Const URL : String; Dest : TStream);
begin
OCurlDownload(URL,Dest);
end;
end.