📄 ftpcli.pas
字号:
function GetSocksPassword: string;
procedure SetSocksPort(NewValue: string);
function GetSocksPort: string;
procedure SetSocksServer(NewValue: string);
function GetSocksServer: string;
procedure SetSocksUserCode(NewValue: string);
function GetSocksUserCode: string;
procedure SetPassive(NewValue: Boolean);
procedure WndProc(var MsgRec: TMessage); virtual;
function FtpCliAllocateHWnd(Method: TWndMethod): HWND; virtual;
procedure FtpCliDeallocateHWnd(WHandle: HWND); virtual;
procedure HandleBackGroundException(E: Exception); virtual;
procedure WMFtpRequestDone(var msg: TMessage);
message WM_FTP_REQUEST_DONE;
procedure WMFtpSendData(var msg: TMessage);
message WM_FTP_SENDDATA;
procedure DestroyLocalStream;
procedure SetLocalStream (Stream:TStream);
procedure SetLocalFileName (FileName:String);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure OpenAsync; virtual;
procedure UserAsync; virtual;
procedure PassAsync; virtual;
procedure ConnectAsync; virtual;
procedure QuitAsync; virtual;
procedure AbortAsync; virtual;
procedure GetAsync; virtual;
procedure ExecGetAsync; virtual;
procedure ReceiveAsync; virtual;
procedure PutAsync; virtual;
procedure ExecPutAsync; virtual;
procedure TransmitAsync; virtual;
procedure AppendAsync; virtual;
procedure ExecAppendAsync; virtual;
procedure AppendFileAsync; virtual;
procedure ExecDirAsync; virtual;
procedure DirAsync; virtual;
procedure ExecLsAsync; virtual;
procedure LsAsync; virtual;
procedure TypeSetAsync; virtual;
procedure TypeBinaryAsync; virtual;
procedure TypeAsciiAsync; virtual;
procedure PwdAsync; virtual;
procedure CwdAsync; virtual;
procedure CDupAsync; virtual;
procedure DirectoryAsync; virtual;
procedure ListAsync; virtual;
procedure SystAsync; virtual;
procedure SystemAsync; virtual;
procedure SizeAsync; virtual;
procedure FileSizeAsync; virtual;
procedure MkdAsync; virtual;
procedure MkdirAsync; virtual;
procedure RmdAsync; virtual;
procedure RmdirAsync; virtual;
procedure DeleAsync; virtual;
procedure DeleteAsync; virtual;
procedure RenFromAsync; virtual;
procedure RenToAsync; virtual;
procedure RenAsync; virtual;
procedure RenameAsync; virtual;
procedure QuoteAsync; virtual;
procedure DoQuoteAsync; virtual;
procedure AbortXferAsync; virtual;
procedure RestAsync; virtual;
procedure RestGetAsync; virtual;
procedure RestartGetAsync; virtual;
procedure RestPutAsync; virtual;
procedure RestartPutAsync; virtual;
property Handle : HWND read FWindowHandle;
property LastResponse : String read FLastResponse;
property ErrorMessage : String read FErrorMessage;
property DnsResult : String read FDnsResult;
property SizeResult : LongInt read FSizeResult;
property DirResult : String read FDirResult;
property ControlSocket : TWSocket read FControlSocket;
property DataSocket : TWSocket read FDataSocket;
property Connected : Boolean read GetConnected;
property StatusCode : LongInt read FStatusCode;
property ByteCount : LongInt read FByteCount;
property State : TFtpState read FState;
property RequestType : TFtpRequest read FRequestType;
property Options : TFtpOptions read FOptions
write FOptions;
property LocalStream : TStream read FLocalStream
write SetLocalStream;
property ResumeAt : LongInt read FResumeAt
write FResumeAt;
property HostName : String read FHostName
write FHostName;
property Port : String read FPort
write FPort;
property LocalAddr : String read FLocalAddr
write FLocalAddr; {bb}
property UserName : String read FUserName
write FUserName;
property PassWord : String read FPassWord
write FPassWord;
property HostDirName : String read FHostDirName
write FHostDirName;
property HostFileName : String read FHostFileName
write FHostFileName;
property LocalFileName : String read FLocalFileName
write SetLocalFileName;
property DisplayFileFlag : Boolean read FDisplayFileFlag
write FDisplayFileFlag;
property Binary : Boolean read GetBinary
write SetBinary;
property Passive : Boolean read FPassive
write SetPassive;
property ShareMode : TFtpShareMode read GetShareMode
write SetShareMode;
property DisplayFileMode : TFtpDisplayFileMode read GetDisplayFileMode
write SetDisplayFileMode;
property ConnectionType : TFtpConnectionType read GetConnectionType
write SetConnectionType;
property ProxyServer : string read FProxyServer
write FProxyServer;
property ProxyPort : string read FProxyPort
write FProxyPort;
property SocksPassword : string read GetSocksPassword
write SetSocksPassword;
property SocksPort : string read GetSocksPort
write SetSocksPort;
property SocksServer : string read GetSocksServer
write SetSocksServer;
property SocksUserCode : string read GetSocksUserCode
write SetSocksUserCode;
property OnDisplay : TFtpDisplay read FOnDisplay
write FOnDisplay;
property OnDisplayFile : TFtpDisplay read FOnDisplayFile
write FOnDisplayFile;
property OnError : TFTPDisplay read FOnError
write FOnError;
property OnCommand : TFtpCommand read FOnCommand
write FOnCommand;
property OnResponse : TNotifyEvent read FOnResponse
write FOnResponse;
property OnProgress : TFtpProgress read FOnProgress
write FOnProgress;
property OnSessionConnected : TSessionConnected read FOnSessionConnected
write FOnSessionConnected;
property OnSessionClosed : TSessionClosed read FOnSessionClosed
write FOnSessionClosed;
property OnRequestDone : TFtpRequestDone read FOnRequestDone
write FOnRequestDone;
property OnStateChange : TNotifyEvent read FOnStateChange
write FOnStateChange;
property OnReadyToTransmit : TFtpReadyToTransmit read FOnReadyToTransmit
write FOnReadyToTransmit;
property OnBgException : TBgExceptionEvent read FOnBgException
write FOnBgException;
end;
TFtpClient = class(TCustomFtpCli)
protected
FTimeout : Integer; { Given in seconds }
FTimeStop : LongInt; { Milli-seconds }
FMultiThreaded : Boolean;
FTerminated : Boolean;
FOnMessagePump : TNotifyEvent;
function Progress : Boolean; override;
function Synchronize(Proc : TFtpNextProc) : Boolean; virtual;
function WaitUntilReady : Boolean; virtual;
public
constructor Create(AOwner: TComponent); override;
procedure MessagePump;
function Open : Boolean;
function User : Boolean;
function Pass : Boolean;
function Connect : Boolean;
function Cwd : Boolean;
function Pwd : Boolean;
function CDup : Boolean;
function TypeSet : Boolean;
function TypeBinary : Boolean;
function TypeAscii : Boolean;
function Get : Boolean;
function Put : Boolean;
function RestPut : Boolean;
function RestartPut : Boolean;
function Quit : Boolean;
function Abort : Boolean;
function Receive : Boolean;
function Transmit : Boolean;
function Append : Boolean;
function AppendFile : Boolean;
function Dir : Boolean;
function Directory : Boolean;
function Ls : Boolean;
function List : Boolean;
function Mkd : Boolean;
function Mkdir : Boolean;
function Ren : Boolean;
function Rename : Boolean;
function Dele : Boolean;
function Delete : Boolean;
function Rmd : Boolean;
function Rmdir : Boolean;
function Syst : Boolean;
function System : Boolean;
function Size : Boolean;
function FileSize : Boolean;
function Quote : Boolean;
function DoQuote : Boolean;
function AbortXfer : Boolean;
function RestGet : Boolean;
function RestartGet : Boolean;
{$IFDEF NOFORMS}
property Terminated : Boolean read FTerminated
write FTerminated;
property OnMessagePump : TNotifyEvent read FOnMessagePump
write FOnMessagePump;
{$ENDIF}
published
property Timeout : Integer read FTimeout write FTimeout;
property MultiThreaded : Boolean read FMultiThreaded write FMultiThreaded;
property HostName;
property Port;
property LocalAddr; {bb}
property UserName;
property PassWord;
property HostDirName;
property HostFileName;
property LocalFileName;
property DisplayFileFlag;
property Binary;
property ErrorMessage;
property ShareMode;
property Options;
property ConnectionType;
property ProxyServer;
property SocksPassword;
property SocksPort;
property SocksServer;
property SocksUserCode;
property OnDisplay;
property OnDisplayFile;
property OnCommand;
property OnResponse;
property OnProgress;
property OnSessionConnected;
property OnSessionClosed;
property OnRequestDone;
property OnStateChange;
property OnReadyToTransmit;
property OnBgException;
end;
procedure Register;
implementation
uses WinSock;
{$IFNDEF WIN32}
const
HFILE_ERROR = $FFFF;
{$ENDIF}
{$B-} { Do not evaluate boolean expressions more than necessary }
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure Register;
begin
RegisterComponents('FPiette', [TFtpClient]);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{$IFNDEF WIN32}
procedure SetLength(var Str : String; Len : Integer);
begin
Str[0] := chr(Len);
end;
{$ENDIF}
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{$IFDEF VER80}
function TrimLeft(Str : String) : String;
var
i : Integer;
begin
if Str[1] <> ' ' then
Result := Str
else begin
i := 1;
while (i <= Length(Str)) and (Str[i] = ' ') do
i := i + 1;
Result := Copy(Str, i, Length(Str) - i + 1);
end;
end;
{$ENDIF}
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function GetFileSize(const FileName: string): LongInt;
var
SearchRec: TSearchRec;
begin
if FindFirst(ExpandFileName(FileName), faAnyFile, SearchRec) = 0 then begin
Result := SearchRec.Size;
SysUtils.FindClose(SearchRec);
end
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -