📄 ftpcli.pas
字号:
Dec 27, 1996 Added transmit functions
Changed all procedure to function returning boolean status
Aug 13, 1997 Added multiline response support
Added support for strange Microsoft PWS FTP behaviour
Sep 10, 1997 Added support for Dir and Ls commands
Corrected bugs to enable correct use of separate commands
Oct 16, 1997 V2.07 Adapted for changes in TWSocket object
Added FtpCliVersion constant
Nov 25, 1997 V2.08 Accept 250 as well as 226 for succesfull file transfert
Suggested by fdragon@world-net.net
Nov 26, 1997 V2.09 don't display error message in the receive event when
the socket is no more connected.
Nov 29, 1997 V2.10 added Mkd and Mkdir functions to create a directory.
As suggested by Christian R鰏ner <christian.roesner@usa.net>
Dec 04, 1997 V2.11 Added Ren, Dele, Rmd functions
As suggested by Frank Riemann <riemann@student.uni-kl.de>
Changed Mkd and Mkdir functions to take HostFileName to
specify the directory name. This is more consistent with the
rest of the component usage.
Dec 29, 1997 V2.12 Added a TrimLeft function for Delphi 1
Dec 30, 1997 V2.13 Added Syst and System commands as suggested by
Fire Dragon <fdragon@nosferatu.world-net.net>
Added the LastResponse property
Corrected a message ("Daniel Fazekas" <fdsoft@dns.gyor-ph.hu>)
Jan 10, 1998 V2.14 Accept response 150 and 125 for Get Submitted by Fire
Dragon <fdragon@nosferatu.world-net.net>.
Added a quick reference for most used properties and methods.
Made TFtpCli a TComponent descendant.
Added the Size, FileSize, Quote, DoQuote, RestartGet method.
Made ControlSocket a readonly property (allow easy DNSLookup).
Added a Port property.
Jan 25, 1998 V2.15
Completely revised to make it asynchronous.
This means that a new set of functions is born. They all have
a name ending with Async. For example GetAsync. Asynchronous
means that when you call the function, it returns almost
immediately. The operation is done in the background.
The asynchronous operation allows to make several request
simultaneously WITHOUT using threads. Just use two or more
TFtpClient and call each GetAsync (or other) method as those
method returns almost instantly, all the request will be done
in the background, generating the OnRequestDone when finished.
Added a State property
This allows to check for component work in the background.
You can call methods only when State = ftpReady (except the
Abort method which can be called at any time)
The Asynchronous methods are the prefered ones.
Added Pwd command
Returns the current working directory on the server.
Added CDup command
Change to parrent directory on FTP server.
Added DirResult property
Parse the LastResponse property to return the directory.
Do no always work when the server returns multi-line responses.
(updated by Pwd, Cwd, CDup and Mkd commands).
Changed function IsConnected to Connected, a read-only property.
It's more object oriented.
Replaced file I/O by stream I/O.
It's the first step to allow Stream I/O outside of the component.
New sample application (Delphi only now, CPP later).
Every command has now a button to excercize it
(async version only)
The synchronous commands (old commands) are implemented by
calling the asynchronous version and waiting.
Multi-threaded property
Tells the component how to wait for command completion.
Removed the TWait component use.
No need to have a TWait component.
Jan 31, 1998 V2.16 Accept response 150 and 125 for Put.
Feb 01, 1998 V2.17 Added intermediate message for OnRequestDone event
Feb 02, 1998 V2.18 Corrected a bug: all sync function returned always FALSE.
Added User and Pass synchronous functions.
Made PutAsync return ftpPutAsync in the OnrequestDone event.
Feb 04, 1998 V2.19 Added an OnCommand event to give a chance to the user to
modify the commands to make some custom commands. Also added the
OnResponse event to allow custom commands to get the response
and alter it as necessary.
Feb 15, 1998 V2.20 Added a FindClose after the FindFirst in GetFileSize routine
as pointed by "Daniel Fazekas" <fdsoft@dns.gyor-ph.hu>
Feb 21, 1998 V2.21 Enabled progress updated on put
Feb 22, 1998 V2.22 Accept result code 250 after Put command
Implemented Append and AppendFile commands
Mar 07, 1998 V2.23 Made RequestType a R/O property
Mar 15, 1998 V2.24 Reordered PORT/REST/RETR
Added a port command
The ByteCount passed to OnProgress now take into account the
restart byte offset.
Renamed Display to TriggerDisplay and made it virtual
Used TriggerDisplay everywhere.
Modified the Timeout mechanism to reset the timeout each
time the OnProgress event is called.
Abort command call CancelDnsLookup approprietedly
Mar 27, 1998 V2.25 Adapted for C++Builder 3
Avr 01, 1998 V2.26 Made a valid LastResponse and ErrorMessage when DNS lookup
failed. Added some compiler options.
Apr 10, 1998 V2.27 Added some ftpFctCwd in some highlevel functions.
Suggested by Ray Andrews <ray_andrews@steeltoad.com>.
Apr 13, 1998 V2.28 Save error code when the data connection is closed to use
it later to return the status for file transfert.
Implemented passive mode, with help from Yaron Golan
<yarong@shani.com>. A new property Passive enable this mode.
Put do not work [yet] is passive mode.
Apr 14, 1998 V2.29 Made passive mode PUT work.
Added ShareMode property (see TFileStream.Create on-line help)
Made ResumeAt property.
Apr 15, 1998 V2.30 Added the OnReadyToTransmit event.
Correctly handled error when local file not found.
Checked if socket connected in SendCommand
Apr 22, 1998 V2.31 Corrected CDupAsync procedure (thanks to Eric
Engler englere@swcp.com)
Apr 26, 1998 V2.32 Added TypeBinary and TypeAscii just to help a little bit.
May 01, 1998 V2.33 Added check for continuation lines in NextxPutAsync
May 05, 1998 V2.34 Added some more delay in WMFtpCloseData.
May 13, 1998 V2.35 In passive mode STOR or APPE, changed the sequence: now
wait for connection established before sending the STOR or APPE
command to FTP server.
May 19, 1998 V2.36 TransfertStats made virtual.
Jun 25, 1998 V2.37 Revised code for 'connection reset by peer' syndrome
Jul 09, 1998 V2.38 Adpted for Delphi 4
Jul 23, 1998 V2.39 Made ResumeAt property R/W
Added code from Yaron Golan <yarong@shani.com> to fix PASV + REST
and to add OnDisplayFile code to view a file on the fly.
Aug 04, 1998 V2.40 Frank Neuhaus <neuhaus@cpa.de> found a problem in Put command
for some FTP server. See V240 in the comments.
Aug 12, 1998 V2.41 Added 200 to the valid CWD responses.
Aug 18, 1998 V2.42 Added code to accept continuation lines not beginning by
a number and a dash. Thanks to Al Cantu <cantu@bfs.e-mail.com>
for pointing this problem.
Sep 16, 1998 V2.43 Made Synchronize and WaitUntilReady virtual function in
protected section.
Oct 01, 1998 V2.44 Checked for errors in TriggerRequestDone.
Nov 09, 1998 V2.45 Reverted V2.40 changes ! Thanks to Grant Walker
<gw@enternet.com.au> for his help in testing.
Made block size equal to 1514 to minimize packet fragmentation
on ethernet.
Nov 22, 1998 V2.46 changed GetTickCount cast from Integer to LongInt because
of overflows with Delphi 1. Suggested by Terry Byrne
<terryb@fidlar.com>
Dec 22, 1998 V2.47 Corrected DisplayFile which forgot the last character.
Thanks to max@zab1.chita.ru for the bug report.
Handled exceptions while trying to connect data session.
Replaced DisplayFlag by DysplayFileFlag.
Feb 14, 1999 V2.48 Indirectly call winsock functions using wsocket because
wsocket provide runtime dynamic link instead of loadtime link.
This allows a program to use FTP if it discover that winsock is
installed and still run if winsock is not installed.
Mar 13, 1999 V2.49 Added FPutSessionOpened flag and combine it with
FStorAnswerRcvd flag to synchronize start of data sending.
Thanks to Frank Neuhaus for his clear analysis.
Mar 20, 1999 V2.50 Added Options property
Mar 23, 1999 V2.51 Corrected a bug introcuded in last version which truncated
the first character of the second line of a multiline answer on
some servers.
May 04, 1999 V2.52 Corrected an access violation in DataSocketGetDataAvailable.
Thanks to Steve Plegge for pointing that bug.
May 21, 1999 V2.53 Added FRequestResult to ControlSocketDnsLookupDone. Thanks
to Wu'hao <wvhao@263.net> for finding this bug.
Jul 17, 1999 V2.54 Added OnError event and DisplayFileMode property. Thanks to
Pieter Snyman <pgws@iafrica.com> for his work.
Accepted answer 200 for successful rename.
Leho Kraav <macmanos@online.ee> found that some FTP server return
this code.
Cleared FByteCount from PortAsync as suggested by Simon Hoerup
<cas@casdk.com> to help some progress indicator implementation.
Aug 04, 1999 V2.55 Corrected a bug with Delphi 1 where a buffer overflow may
occurs when receiving commands longer than 254 bytes.
Thanks to Craig Johnson <Craig_Johnson@emsinfo.com> for finding it.
Also casted FTimeOut to LongInt for computation to prevent
overflow with Delphi 1 for long timeout.
Aug 12, 1999 V2.56 HandleError was not correctly handling error message !
thank to Kim M鴏g錼d Nielsen <kmn@bcview.com>
Aug 20, 1999 V2.57 Revised conditional compilation, adapted for BCB4, set
compile options same as TWSocket.
Added DnsResult property as suggested by Heedong Lim
<hdlim@dcenlp.chungbuk.ac.kr>. This property is accessible from
OnStateChange when state is ftpWaitingBanner.
Added checks for FLocalStream being destroyed.
Sep 5, 1999 V2.58 Heedong Lim <hdlim@dcenlp.chungbuk.ac.kr> found a missing
assignation to FRequestResult in ControlSocketSessionConnected.
Sep 11, 1999 V2.59 Added OnBgException. Thanks to William Sorensen
<tzimisce@mwaccess.net> for suggesting it.
Oct 30, 1999 V2.60 Changed TargetPort and DataPort from integer to WORD so
that Delphi 1 is able to handle port greater than 32K. Bug and
and fix by Duncan Gold <Gold@esg-us.com>.
Nov 22, 1999 V2.61 Allow continuation lines in all responses.
Nov 24, 1999 V2.62 RestPut command by Alexander Burlakov <alex@helexis.com>
Added RestartPut. Added ftpNoAutoResumeAt option.
Dec 26, 1999 V2.63 Corrected a bug in DoPutAppendAsync.
Jan 24, 1999 V2.64 Added LongInt cast to all GetTickCount.
Apr 01, 2000 V2.65 Removed any set of integer.
Thanks to Grant Black <grant.black@smartmove.co.nz>,
Davie <smatters@smatters.com> and
Stephen Williams <SWilliams@fm.optus.net.au> for their work on
this subject.
Apr 09, 2000 V2.66 Proxy / Socks / Local streams support added.
Pieter Snyman <pgws@iafrica.com> added proxy and socks support.
Eric <erv@sympatico.ca> added stream support (assign LocalStream
property to switch to stream mode and LocalFileName to switch to
normal file mode).
Jun 10, 2000 V2.67 Added NOFORMS conditional compile to be able to build a
program (console mode, dll or other) without using the forms unit
(because forms unit makes programs much bigger). See NOFORMS
related comments in wsocket.pas source file for correct use.
See also OnMessagePump event and Terminated property.
Jul 15, 2000 V2.68 Added ProxyPort property. Handled non standard port when
connecting thru proxy.
Jul 21, 2000 V2.69 Implemented check for ABOR, STAT and QUIT commands so that
it doesn't check if previous command is done.
By Davie <smatters@smatters.com>.
Tomas Lannestedt <proprat@algonet.se> found a bug when using
streams. Now it correctly handled stream clearing.
Sep 17, 2000 V2.70 Eugene Mayevski <Mayevski@eldos.org> moved Controls use
out of NOFORMS way.
Nov 11, 2000 V2.71 Cleared FErrorMessage in ExecAsync. Thanks to Jake Traynham
<jake@comm-unity.net> for finding this bug.
Nov 30, 2000 V2.72 Added a Sleep in DataSocketPutDataSent, and use CloseDelayed
this will prevent some trucated file transfers.
Feb 17, 2001 V2.73 Better WaitUntilReady: check also ftpInternalReady.
By Davie <smatters@smatters.com>.
Jun 16, 2001 V2.74 Added conditional compile for Delphi 6
Jun 18, 2001 V2.75 Use AllocateHWnd and DeallocateHWnd from wsocket.
Jul 26, 2001 V2.76 Accept range 150-159 for status code after RETR command.
Peter Calum <pemca@tdk.dk> found some FTP server returning
unusual status code (and not conforming to RFC !). I don't like to
work arround other's bugs, but in this case this shouldn't hurt
anything.
Jul 28, 2001 V2.77 Cleared FNextRequest in HighLevelAsync and TriggerRequestDone
as suggested by Davie <smatters@smatters.com>.
Added AbortXfer and AbortXferAsync to abort a running transfert
without breaking connection.
Sep 09, 2001 V2.78 Beat Boegli <leeloo999@bluewin.ch> added LocalAddr property
for multihomed hosts.
Sep 13, 2001 V2.79 Bug fix by Beat Boegli <leeloo999@bluewin.ch> related to
his previous changes. Now works with passive mode put.
Nov 02, 2001 V2.80 Added DisplayLastResponse in ControlSocketDataAvailable to
give continuation lines to OnDisplay event.
Accept 250 answer as well as 257 for MKD command as suggested by
Simon Horup <cas@casdk.com>.
Feb 12, 2002 V2.82 "Soltann" <soltann@wanadoo.fr> added code to extract IP
from passive mode reply so that transfer from another server is
possible (See TargetIP in code).
Apr 06, 2002 V2.83 Added code 257 to allowed code list for CDUpAsync as
suggest by <Davie@smatters.com>.
Fixed a problem in ControlSocketSessionClosed where error code was
not checked. Bug found by <Davie@smatters.com>.
Apr 20, 2002 V2.84 Removed useless units from uses clause.
Jun 28, 2002 V2.85 Removed check for ftpFctPut and FPassive in
TriggerRequestDone which cause trouble with passive mode and sync
operation. Thanks to "Gunnar" <gulb@gmx.de>.
Oct 26, 2002 V2.85 Use wsoNoReceiveLoop option with data session.
Set OnSessionAvalable handler before calling listen as suggested
by Gunnar <gulb@gmx.de>.
Nov 11, 2002 V2.86 Changed FtpCliDeallocateHWnd argument from HWND to Cardinal
becasue BCB doesn't like HWND when deriving acomponent from
TFtpCli (BCB bug ?).
Jan 04, 2003 V2.87 Published OnError event
Feb 15, 2003 V2.88 Ignore empty lines in responses from server. Thansk to
Chris Rendell <appsolca@yahoo.ca> for finding this one.
Oct 26, 2003 V2.90 Added FEAT, MLSD, MDTM commands - not supported by all
servers (not IIS5) added LastMultiResponse with last command
response, may be multiple lines, all with CRLF by Angus Robertson,
angus@magsys.co.uk
Jan 03, 2004 V2.91 Made OnMessagePump public, use it when MultiThread is true.
May 20, 2004 V2.92 Implemented FTPS (SSL) support. Require ICS-SSL.
Aug 20, 2004 V2.93 Use MsgWaitForMultipleObjects in WaitUntil ready instead
of simple Sleep(). This make CPU use slow down considerably.
Aug 22, 2004 V2.94 Angus Robertson, added MFMT modify file modification time
added MD5 command to get file hash sum (use FileMD5(file) in
md5.pas to check it)
added SupportedExtensions property set of TFtpFeat which features
server supports (note SupportedExtensions replaces SupportXXX
flags which have gone)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -