[video=youtube;Wi0GFlmiL0s]http://www.youtube.com/watch?v=Wi0GFlmiL0s&feature=youtu.be[/video]
This is not complete yet but, does download from a FTP server successfully, checks size of files to determine changes in files.
TO DO: I still have to create the routines for extracting the zip files into the correct directory.
---------- Post added 08-03-2012 at 09:58 AM ---------- Previous post was 25-01-2012 at 04:24 PM ----------
I decided to just release the code for this project enjoy!
I have not complete the decompression process but left code I was working with commented out
I have used indy 10 components for FTP
This is not complete yet but, does download from a FTP server successfully, checks size of files to determine changes in files.
TO DO: I still have to create the routines for extracting the zip files into the correct directory.
---------- Post added 08-03-2012 at 09:58 AM ---------- Previous post was 25-01-2012 at 04:24 PM ----------
I decided to just release the code for this project enjoy!
I have not complete the decompression process but left code I was working with commented out
I have used indy 10 components for FTP
Code:
procedure TfrmMain.tmrScrollTextTimer(Sender: TObject);
begin
// Scrolling message
lblScrollingMessage.Left:= lblScrollingMessage.Left-1;
If lblScrollingMessage.Left <= 0 Then
lblScrollingMessage.Left:= 705;
end;
{//
procedure DecompressFiles(const Filename, DestDirectory : String);
var
dest,s : String;
decompr : TDecompressionStream;
infile, outfile : TFilestream;
i,l,c : Integer;
begin
// IncludeTrailingPathDelimiter (D6/D7 only)
dest := IncludeTrailingPathDelimiter(DestDirectory);
infile := TFileStream.Create(Filename,fmOpenRead);
try
// number of files
infile.Read(c,SizeOf(c));
for i := 1 to c do
begin
//read filename
infile.Read(l,SizeOf(l));
SetLength(s,l);
infile.Read(s[1],l);
// read filesize
infile.Read(l,SizeOf(l));
// decompress the files and store it
s := dest+s; //include the path
outfile := TFileStream.Create(s,fmCreate);
decompr := TDecompressionStream.Create(infile);
try
outfile.CopyFrom(decompr,l);
finally
outfile.Free;
decompr.Free;
end;
end;
finally
infile.Free;
end;
end;
//}
procedure TfrmMain.FormCreate(Sender: TObject);
begin
Webbrowser1.Navigate('http://www.lomcn.co.uk/forum/search.php?searchid=17090');
end;
procedure TfrmMain.imgCloseClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TfrmMain.imgCloseOverClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TfrmMain.imgCloseMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
imgCloseOver.Visible := True;
end;
procedure TfrmMain.imgCloseOverMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if X <= 1 then
begin
imgCloseOver.Visible := False;
end;
if X >= 57 then
begin
imgCloseOver.Visible := False;
end;
if Y <= 1 then
begin
imgCloseOver.Visible := False;
end;
if Y >= 60 then
begin
imgCloseOver.Visible := False;
end;
Application.ProcessMessages;
end;
procedure TfrmMain.imgPatchOverMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
imgPatch.Visible := False;
imgPatchOver.Visible := True;
end;
procedure TfrmMain.imgPatchMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
imgPatch.Visible := False;
imgPatchOver.Visible := True;
end;
procedure TfrmMain.imgPatchOverClick(Sender: TObject);
var
//Local Variables
FileCount : Integer;
FTPFileSize : Integer;
FilesFtp : TStrings;
FileSize : Integer;
numFiles : Integer;
I : Integer;
FilePath : String;
FileName : String;
searchResult : TSearchRec;
begin
//Check if already connected
if FTP.Connected then
begin
FTP.Disconnect;
end
else
begin
FTP := TIdFTP.Create( nil );
//Built using filezilla server.
with FTP do try
Passive := True; //adjust the firewall
Host := '127.0.0.1'; //set the host
Username := 'anonymous'; //set the user name
Password := 'admin'; //set a password
Port:= 21; //set the port
Connect;
ChangeDir('/') //move to root directory
finally
end;
if (FTP.Size('/') > 0)then
else
begin
//populated the list box with all files FTP server
FTP.list(ListBox1.Items,'*.ZIP',false);
//store the TString values from the list box
FilesFtp := ListBox1.Items;
//Default directory
FilePath := 'C:\Test\Test2\';
//count the files in the list box
numFiles := ListBox1.Count;
//Inialize the Files download
FileCount := 0;
for i := 0 to numFiles -1 do
begin
lblCurrentFile.Caption := 'Downloading.....' + IntToStr(FileCount + 1 ) + '/' + IntToStr(numFiles) + '...' + FilesFtp[i];
Application.ProcessMessages;
ProgressBar1.Max := FTP.Size(FilesFtp[i]);
Application.ProcessMessages;
//Set the file name
FileName := FilesFtp[i];
//Compare the file size from ftp directory to user directory
FindFirst(FilePath + FileName, faAnyFile, searchResult);
// If the file does not exist
if searchResult.Name <> FilesFtp[i] then
begin
//File not found download it
lblCurrentFile.Caption := 'Downloading.....' + IntToStr(FileCount + 1 ) + '/' + IntToStr(numFiles) + '...' + FilesFtp[i];
Application.ProcessMessages;
FTP.Get(FilesFtp[I], FilePath + FilesFtp[i], true, false); //Download files.
Application.ProcessMessages;
ProgressBar1.Position := FTP.Size(FilesFtp[i]);
Application.ProcessMessages;
//call decompression procdure
//DecompressFiles(FileName, FilePath + FileName);
//Count files downloaded
FileCount := FileCount + 1;
end
else
begin
repeat
//Continue the process until all records are tryed
until FindNext(searchResult) <> 0;
//Close the search
FindClose(searchResult);
// Set the FTP File size
FTPFileSize := FTP.Size(FilesFtp[i]);
// Set the system file size
FileSize := searchResult.Size;
//Compare the two sizes
if FTPFileSize = FileSize then
//Don't bother to download it is the same
else
begin
//IdFTP.Get('SourceFIle: String', 'Destination File: String',
// 'OverWrite: Boolean', 'Resume : Boolean');
FTP.Get(FilesFtp[I], FilePath + FilesFtp[i], true, false); //Download files.
ProgressBar1.Max := FTP.Size(FilesFtp[i]);
ProgressBar1.Position := FTP.Size(FilesFtp[i]);
Application.ProcessMessages;
//DecompressFiles(FilesFtp[I],'C:\Test\Test2\'+ FileName);
//Add one to the files downloaded, count
FileCount := FileCount + 1;
end;
end;
end;
//ShowMessage('Files downloaded = '+IntToStr(FileCount));
FTP.Disconnect; //Disconnect
Application.ProcessMessages;
imgPatch.Visible := False;
imgPlay.Visible := True;
Application.ProcessMessages;
imgPlay.BringToFront;
end;
end;
end;
procedure TfrmMain.imgPlayMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
imgPlay.Visible := False;
imgPlayOver.Visible := True;
end;
end.
Last edited: