A38 work
This commit is contained in:
parent
d85a08090a
commit
484bfdf0a7
|
@ -5,10 +5,14 @@ Unit m_Tcp_Client_FTP;
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
// SysUtils, //wordrec
|
|
||||||
m_io_Sockets,
|
m_io_Sockets,
|
||||||
m_Tcp_Client;
|
m_Tcp_Client;
|
||||||
|
|
||||||
|
Const
|
||||||
|
ftpResOK = 0;
|
||||||
|
ftpResFailed = 1;
|
||||||
|
ftpResBadData = 2;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
WordRec = Record
|
WordRec = Record
|
||||||
Lo : Byte;
|
Lo : Byte;
|
||||||
|
@ -30,8 +34,8 @@ Type
|
||||||
Function OpenConnection (HostName: String) : Boolean;
|
Function OpenConnection (HostName: String) : Boolean;
|
||||||
Function Authenticate (Login, Password: String) : Boolean;
|
Function Authenticate (Login, Password: String) : Boolean;
|
||||||
Function ChangeDirectory (Str: String) : Boolean;
|
Function ChangeDirectory (Str: String) : Boolean;
|
||||||
Function SendFile (Passive: Boolean; FileName: String) : Boolean;
|
Function SendFile (Passive: Boolean; FileName: String) : Byte;
|
||||||
Function GetFile (Passive: Boolean; FileName: String) : Boolean;
|
Function GetFile (Passive: Boolean; FileName: String) : Byte;
|
||||||
Procedure CloseConnection;
|
Procedure CloseConnection;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -41,9 +45,6 @@ Uses
|
||||||
m_FileIO,
|
m_FileIO,
|
||||||
m_Strings;
|
m_Strings;
|
||||||
|
|
||||||
Const
|
|
||||||
ftpDefaultDataPort = 20;
|
|
||||||
|
|
||||||
Constructor TFTPClient.Create (NetI: String);
|
Constructor TFTPClient.Create (NetI: String);
|
||||||
Begin
|
Begin
|
||||||
Inherited Create(NetI);
|
Inherited Create(NetI);
|
||||||
|
@ -158,14 +159,14 @@ Begin
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function TFTPClient.SendFile (Passive: Boolean; FileName: String) : Boolean;
|
Function TFTPClient.SendFile (Passive: Boolean; FileName: String) : Byte;
|
||||||
Var
|
Var
|
||||||
F : File;
|
F : File;
|
||||||
Buffer : Array[1..8 * 1024] of Char;
|
Buffer : Array[1..8 * 1024] of Char;
|
||||||
Res : LongInt;
|
Res : LongInt;
|
||||||
OK : Boolean;
|
OK : Boolean;
|
||||||
Begin
|
Begin
|
||||||
Result := False;
|
Result := ftpResFailed;
|
||||||
|
|
||||||
If Not FileExist(FileName) Then Exit;
|
If Not FileExist(FileName) Then Exit;
|
||||||
|
|
||||||
|
@ -193,25 +194,23 @@ Begin
|
||||||
|
|
||||||
CloseDataSession;
|
CloseDataSession;
|
||||||
|
|
||||||
Result := GetResponse = 226;
|
If GetResponse = 226 Then
|
||||||
|
Result := ftpResOK;
|
||||||
End Else Begin
|
End Else Begin
|
||||||
// If IsPassive Then
|
Result := ftpResBadData;
|
||||||
// WriteLn ('DEBUG unable to connect to FTP server for data session')
|
|
||||||
// Else
|
|
||||||
// WriteLn ('DEBUG unable to establish data session on port ', DataPort);
|
|
||||||
|
|
||||||
CloseDataSession;
|
CloseDataSession;
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function TFTPClient.GetFile (Passive: Boolean; FileName: String) : Boolean;
|
Function TFTPClient.GetFile (Passive: Boolean; FileName: String) : Byte;
|
||||||
Var
|
Var
|
||||||
F : File;
|
F : File;
|
||||||
Res : LongInt;
|
Res : LongInt;
|
||||||
Buffer : Array[1..8 * 1024] of Char;
|
Buffer : Array[1..8 * 1024] of Char;
|
||||||
OK : Boolean;
|
OK : Boolean;
|
||||||
Begin
|
Begin
|
||||||
Result := False;
|
Result := ftpResFailed;
|
||||||
|
|
||||||
If FileExist(FileName) Then Exit;
|
If FileExist(FileName) Then Exit;
|
||||||
|
|
||||||
|
@ -239,12 +238,10 @@ Begin
|
||||||
|
|
||||||
CloseDataSession;
|
CloseDataSession;
|
||||||
|
|
||||||
Result := GetResponse = 226;
|
If GetResponse = 226 Then
|
||||||
|
Result := ftpResOK;
|
||||||
End Else Begin
|
End Else Begin
|
||||||
// If IsPassive Then
|
Result := ftpResBadData;
|
||||||
// WriteLn ('DEBUG unable to connect to FTP server for data session')
|
|
||||||
// Else
|
|
||||||
// WriteLn ('DEBUG unable to establish data session on port ', DataPort);
|
|
||||||
|
|
||||||
CloseDataSession;
|
CloseDataSession;
|
||||||
End;
|
End;
|
||||||
|
|
Loading…
Reference in New Issue