Browse Source

* Added program to test downloader class

git-svn-id: trunk@5213 -
michael 19 years ago
parent
commit
f9966bdc06
3 changed files with 35 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 11 0
      utils/fppkg/pkgwget.pp
  3. 23 0
      utils/fppkg/testdownload.pp

+ 1 - 0
.gitattributes

@@ -7797,6 +7797,7 @@ utils/fppkg/pkgwget.pp svneol=native#text/plain
 utils/fppkg/rep2xml.lpi svneol=native#text/plain
 utils/fppkg/rep2xml.lpr svneol=native#text/plain
 utils/fppkg/reptest.pp svneol=native#text/plain
+utils/fppkg/testdownload.pp svneol=native#text/plain
 utils/fprcp/Makefile svneol=native#text/plain
 utils/fprcp/Makefile.fpc svneol=native#text/plain
 utils/fprcp/Readme.txt svneol=native#text/plain

+ 11 - 0
utils/fppkg/pkgwget.pp

@@ -15,6 +15,7 @@ Type
     Procedure FTPDownload(Const URL : String; Dest : TStream); override;
     Procedure HTTPDownload(Const URL : String; Dest : TStream); override;
  Public
+    Constructor Create(AOWner : TComponent); override;
     Property WGet : String Read FWGet Write FWGet; 
  end;   
 
@@ -22,6 +23,14 @@ implementation
 
 uses process,pkgmessages;
 
+Constructor TWGetDownloader.Create(AOWner : TComponent); 
+
+begin
+  Inherited;
+  wget:='wget';
+end;
+    
+
 Procedure TWGetDownloader.WGetDownload(Const URL : String; Dest : TStream);
 
 Var
@@ -59,4 +68,6 @@ begin
   WGetDownload(URL,Dest);
 end;
 
+initialization
+  DownloaderClass:=TWGetDownloader;
 end.

+ 23 - 0
utils/fppkg/testdownload.pp

@@ -0,0 +1,23 @@
+program testdownload;
+
+uses 
+  Classes,
+  pkgwget, // Including this sets the Downloaderclass. Replace with downloader you want...
+  pkgdownload;
+
+Var
+  F : TFileStream;
+  
+begin
+  F:=TFileStream.Create('fpc.html',fmcreate);
+  Try
+    With DownloaderClass.Create(Nil) do
+      try
+        Download('http://www.freepascal.org',F);
+      Finally
+        Free;
+      end;
+  finally
+    F.Free;
+  end;
+end.