Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: TIdFTP: Can not resume file more 2 GB
| Subject: | Re: TIdFTP: Can not resume file more 2 GB |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Thu, 13 Dec 2007 09:49:22 |
"Alexe Bilchenko" <alexei.bilchenko@impet.com> wrote in message
news:4760f81d@newsgroups.borland.com...
> I use latest indy 10 (Download 2 weeks ago)
What you have shown is NOT the latest Indy 10 from 2 weeks ago. It is an
older version from LAST YEAR! The TIdStream class does not exist in Indy
anymore. It was removed earlier this year. Write() accepts a generic
TStream now.
Looking at the truely latest version, I do see that the Position property
(which is an Int64 on D6 and higher) is still being assigned to an Integer
variable. That will need to be fixed.
> Maybe can use simple code:
> ASize := AStream.Size - AStream.Position;
That is not the problem. Besides, the current version already subtracts the
Position when ASize is -1 on input:
if ASize < 0 then begin //"-1" All from current position
LBufSize := AStream.Position;
ASize := AStream.Size;
//todo1 is this step required?
AStream.Position := LBufSize;
ASize := ASize - LBufSize; // <-- here
end
> My code:
> i64BytesSent := FTPClient.Size(DestFileName);
> Resume := BytesSent > - 1;
You should check for 0, not -1. -1 indicates that Size() is not implemented
on the server. But 0 would indicate that the file exists but is empty.
Besides, you wouldn't need to resume if the file is 0 bytes, as there would
be no seeking involved.
> Stream.Position := i64BytesSent;
If Size() returns -1, you are seeking your stream to an invalid Position. A
more accurate way to resume would be as follows:
i64BytesSent := FTPClient.Size(DestFileName);
if i64BytesSent < 0 then i64BytesSent := 0;
Stream.Position := i64BytesSent;
FTPClient.Put(Stream, DestFileName, i64BytesSent > 0);
Gambit