⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overbyte.ics.ftpclient.pas

📁 搜索百度MP3并下载源码.批量下载.百度TOP100等
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        procedure   MlsdAsync;       virtual;  
        procedure   MlstAsync;       virtual;  
        procedure   FeatAsync;       virtual;
        procedure   MdtmAsync;       virtual;  
        procedure   MdtmyyAsync;     virtual;  

        property    LastResponse    : String                 read  FLastResponse;
        property    LastMultiResponse : String               read  FLastMultiResponse;  { V2.90  multiple lines }
        property    ErrorMessage    : String                 read  FErrorMessage;
        property    DnsResult       : String                 read  FDnsResult;
        property    SizeResult      : LongInt                read  FSizeResult;
        property    DirResult       : String                 read  FDirResult;
        property    ControlSocket   : TFtpWSocket            read  FControlSocket;
        property    DataSocket      : TFtpWSocket            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    SupportMDTMYY   : Boolean                read  FSupportMDTMYY ; { V2.90 does server support set remote date }
        property    SupportMDTM     : Boolean                read  FSupportMDTM ;   { V2.90 does server support get remote date }
        property    SupportMLST     : Boolean                read  FSupportMLST ;   { V2.90 does server support new list stuff  }
        property    MLSTFacts       : String                 read  FMLSTFacts ;     { V2.90 specific new list stuff supported   }
        property    RemFacts        : String                 read  FRemFacts ;      { V2.90 facts about remote file             }
        property    SupportSIZE     : Boolean                read  FSupportSIZE ;   { V2.90 does server support remote file size }
        property    RemFileDT       : TDateTime              read  FRemFileDT       { V2.90 date/time for MdtmAsync }
                                                             write FRemFileDT ;     {       and MdtmYYYYAsync; }
        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 DataPortRangeStart : DWORD                  read  FDataPortRangeStart
                                                             write SetDataPortRangeStart; {JT}
        property DataPortRangeEnd   : DWORD                  read  FDataPortRangeEnd
                                                             write SetDataPortRangeEnd; {JT}
        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;
    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: {$IFDEF ICS_COMPONENT}TComponent
                                   {$ELSE}TObject{$ENDIF}); 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;
        function    Mlsd       : Boolean;    { V2.90 machine list directory     }
        function    Mlst       : Boolean;    { V2.90 machine list file          }
        function    Feat       : Boolean;    { V2.90 supported extensions       }
        function    Mdtm       : Boolean;    { V2.90 get file modification time }
        function    Mdtmyy     : Boolean;    { V2.90 set file modification time }
    {$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 DataPortRangeStart; {JT}
        property DataPortRangeEnd; {JT}
        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 OnError;
        property OnResponse;
        property OnProgress;
        property OnSessionConnected;
        property OnSessionClosed;
        property OnRequestDone;
        property OnStateChange;
        property OnReadyToTransmit;
        property OnBgException;
    end;

{$IFDEF ICS_COMPONENT}
procedure Register;
{$ENDIF}

implementation


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{$IFDEF ICS_COMPONENT}
procedure Register;
begin
  RegisterComponents('FPiette', [TFtpClient]);
end;
{$ENDIF}


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function GetFileSize(const FileName: string): LongInt;
var
    SearchRec: TSearchRec;
begin
    if Borland.Vcl.SysUtils.FindFirst(
           ExpandFileName(FileName), faAnyFile, SearchRec) = 0 then begin
        Result := SearchRec.Size;
        Borland.Vcl.SysUtils.FindClose(SearchRec);
    end
    else
        Result := -1;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Step over blank spaces                                                    }
{ Return -1 if end of string found before non blank character               }
function StpBlk(const Data : String; var nIndex : Integer) : Integer;
begin
    while (nIndex <= Length(Data)) and
          ((Data[nIndex] = ' ') or
           (Data[nIndex] = #9) or
           (Data[nIndex] = #13) or
           (Data[nIndex] = #10)) do
        Inc(nIndex);
    if nIndex > Length(Data) then
        Result := -1
    else
        Result := nIndex;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function GetInteger(
    const Data   : String;
    var   nIndex : Integer;
    out   Number : LongInt) : Integer;
var
    bSign : Boolean;
begin
    Number := 0;
    Result := StpBlk(Data, nIndex);

    if Result < 0 then
        Exit;

    { Remember the sign }
    if (Data[nIndex] = '-') or (Data[nIndex] = '+') then begin
        bSign := (Data[nIndex] = '-');
        Inc(nIndex);
    end
    else
        bSign  := FALSE;

    { Convert any number }
    while (nIndex <= Length(Data)) and
          (Data[nIndex] >= '0') and (Data[nIndex] <= '9') do begin
        Number := Number * 10 + ord(Data[nIndex]) - ord('0');
        Inc(nIndex);
    end;

    { Correct for sign }
    if bSign then
        Number := -Number;

    if nIndex > Length(Data) then
        Result := -1
    else
        Result := nIndex;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function GetQuotedString(
    const Data   : String;
    var   nIndex : Integer;
    out   Dst    : String) : Integer;
begin
    Dst := '';
    Result := StpBlk(Data, nIndex);

    if Result < 0 then
        Exit;

    if Data[nIndex] <> '"' then
        Exit;
    Inc(nIndex);

    while nIndex <= Length(Data) do begin
        if Data[nIndex] <> '"' then
            Dst := Dst + Data[nIndex]
        else begin
            Inc(nIndex);
            if Data[nIndex] <> '"' then
                Break;
            Dst := Dst + Data[nIndex];
        end;
        Inc(nIndex);
    end;

    if nIndex > Length(Data) then
        Result := -1
    else
        Result := nIndex;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function DataToString(Data : TBytes; Len : Integer) : String;
var
    I  : Integer;
    Ch : Byte;
begin
    Result := '';
    I := 0;
    while I < Len do begin
         Ch := Data[I];
         if (Ch < 32) or (Ch > 126) or (Ch = 35) then
             Result := Result + '#' + Format('%02.2d', [Ch])
         else
             Result := Result + Char(Ch);
         Inc(I);
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{* *                                                                     * *}
{* *                            TCustomFtpCli                            * *}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -