Hi haozhe_han
Post by haozhe_hanI use TIdFTPServer to get files from remote,and i want get the rage of speed
when TIdFTPServer storefiles.
but TIdFTPServer does not provide access to any notifications for that. So I
want overriding the virtual
Read() and Write() methods to get I needed.
class TMyFileStream : public TFileStream
{
typedef TFileStream inherited;
__fastcall TMyFileStream(const AnsiString AFileName, Word Mode);/* overload
*/;
int __fastcall Write(const void *Buffer, int Count);
};
int __fastcall TMyFileStream::Write(const void *Buffer, int Count)
{
//i can get send data count in this position,but i don't know which time
send data end.
THandleStream::Write(Buffer,Count);
return 0;
}
sorry,my english is very poor.
Ohh, Your english is fine, it is just better to some use extra words,
that way it is easier to make a good gues if there something
that I don't understand.
I have have not used Indy much, but here is an idea:
DWORD DownloadStartTime = timeGetTime();
int DownloadedBytes = 0;
int __fastcall TMyFileStream::Write(const void *Buffer, int Count)
{
DWORD CurrentTime = timeGetTime();
DWORD TimeSpent = CurrentTime - DownloadStartTime;
DownloadedBytes += Count;
// do some calculation to get the rate
return THandleStream::Write(Buffer,Count);
}
timeGetTime(); returns number of milliseconds since the computer
was last rebooted, but You can see all about that in the Win32 help.
Kind regards
Asger