function Thread:boolean;
var f,g :TFileStream;
{i:Integer;} PositionFehler:Int64; LetzteZeit,Zeit:Cardinal;
begin
Result:=false;
case Form1.ComboBox1.itemindex
of
0:SetLength(Buffer,1);
1:SetLength(Buffer,1024);
2:SetLength(Buffer,1024*2);
3:SetLength(Buffer,1024*4);
4:SetLength(Buffer,1024*64);
end;
//newposi:=0;
lastposi:=0;
f:=TFileStream.Create(form1.E_Quelle.text,fmOpenRead);
if Form1.CB_Resume.Checked
and FileExists(form1.E_Ziel.Text)
then
begin
g:=TFileStream.Create(form1.E_Ziel.Text,fmOpenWrite);
f.Position:=g.Size;
g.Position:=g.Size;
end else begin
g:=TFileStream.Create(form1.E_Ziel.Text,fmCreate);
f.Position:=0;
g.Position:=0;
end;
MaxFileSize:=f.Size
div 1024;
form1.label9.caption:='
of '+inttostr(MaxFileSize)+'
KB';
LetzteZeit:=GetTickCount;
try
while f.Position <= f.Size
do
//for i:=0 to f.Size-f.Position do
begin
try
f.ReadBuffer(buffer,sizeOf(buffer));
form1.label2.Caption:=inttostr(f.Position
div 1024);
Zeit:=GetTickCount-LetzteZeit;
if (Zeit
div 1000) >= 1
then
begin
//newposi:=f.Position;
form1.Label6.Caption:=inttostr((
{newposi}f.Position-lastposi)
div 1024)+'
KB/s';
LetzteZeit:=GetTickCount;
form1.label8.caption:=IntToStr( ( (MaxFileSize-(
{newposi}f.Position
div 1024))
div ( (
{newposi}f.Position-lastposi)
div 1024) )
div 60 )+'
Minuten';
lastposi:=
{newposi}f.Position;
end;
g.WriteBuffer(Buffer,SizeOf(Buffer));
except
on e:
Exception do // e:EReadError; e:EAccessViolation
begin
PositionFehler:=f.Position;
inc(PositionFehler,Length(Buffer));
f.Position:=PositionFehler;
end;
end;
end;
finally
f.Free;
g.Free;
end;
end;