~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/utils/fppkg/pkgsynapse.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{$mode objfpc}
 
2
{$h+}
 
3
unit pkgsynapse;
 
4
 
 
5
interface
 
6
 
 
7
uses Classes,pkgdownload;
 
8
 
 
9
Type
 
10
  TSynapseDownloader = Class(TBaseDownloader)
 
11
  Protected
 
12
    Procedure FTPDownload(Const URL : String; Dest : TStream); override;
 
13
    Procedure HTTPDownload(Const URL : String; Dest : TStream); override;
 
14
 end;
 
15
 
 
16
implementation
 
17
 
 
18
uses sysutils,uriparser,httpsend,ftpsend,pkgmessages;
 
19
 
 
20
Procedure TSynapseDownloader.FTPDownload(Const URL : String; Dest : TStream);
 
21
 
 
22
Var
 
23
  URI : TURI;
 
24
  FN : String;
 
25
  F : TFileStream;
 
26
 
 
27
begin
 
28
  // Download in temporary file.
 
29
  FN:=GetTempFileName();
 
30
  try
 
31
    URI:=ParseURI(URL);
 
32
    with TFTPSend.Create do
 
33
      try
 
34
        if URI.UserName <> '' then
 
35
         begin
 
36
         Username := URI.UserName;
 
37
         Password := URI.Password;
 
38
         end;
 
39
        TargetHost := URI.Host;
 
40
        if (URI.Port<>0) then
 
41
          TargetPort := IntToStr(URI.Port);
 
42
        if not Login then
 
43
          Error(SErrLoginFailed);
 
44
        DirectFileName := FN;
 
45
        DirectFile:=True;
 
46
        If (URI.Path<>'') then
 
47
          if not ChangeWorkingDir(URI.Path) then
 
48
            Error(SErrCWDFailed,[URI.PATH]);
 
49
        BinaryMode:=True;
 
50
        If Not RetrieveFile(URI.Document, False) then
 
51
           Error(SErrGETFailed,[URI.Document]);
 
52
        Logout;
 
53
      finally
 
54
        Free;
 
55
      end;
 
56
    F:=TFileStream.Create(FN,fmOpenRead);
 
57
    Try
 
58
      Dest.CopyFrom(F,0);
 
59
    Finally
 
60
      F.Free;
 
61
    end;
 
62
  finally
 
63
    // Delete temporary file.
 
64
    If FileExists(FN) then
 
65
      DeleteFile(FN);
 
66
  end;
 
67
end;
 
68
 
 
69
Procedure TSynapseDownloader.HTTPDownload(Const URL : String; Dest : TStream);
 
70
 
 
71
begin
 
72
  If Not HttpGetBinary(URL,Dest) then
 
73
     Error(SErrHTTPGetFailed);
 
74
end;
 
75
 
 
76
end.
 
 
b'\\ No newline at end of file'