Directory and FidoNet FTP mailer
This commit is contained in:
parent
2d0cb7a1cc
commit
a31d6f36ff
|
@ -4,7 +4,7 @@ Unit m_TCP_Client;
|
||||||
|
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
{.$DEFINE USESTRINGLIST}
|
{$DEFINE USESTRINGLIST}
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
{$IFDEF USESTRINGLIST}
|
{$IFDEF USESTRINGLIST}
|
||||||
|
|
|
@ -35,7 +35,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) : Byte;
|
Function GetDirectoryList (Passive, Change: Boolean; Str: String) : Boolean;
|
||||||
|
Function SendFile (Passive: Boolean; LocalFile, RemoteFile: String) : Byte;
|
||||||
Function GetFile (Passive: Boolean; FileName: String) : Byte;
|
Function GetFile (Passive: Boolean; FileName: String) : Byte;
|
||||||
Procedure CloseConnection;
|
Procedure CloseConnection;
|
||||||
End;
|
End;
|
||||||
|
@ -99,6 +100,7 @@ End;
|
||||||
Procedure TFTPClient.CloseDataSession;
|
Procedure TFTPClient.CloseDataSession;
|
||||||
Begin
|
Begin
|
||||||
If DataSocket <> NIL Then Begin
|
If DataSocket <> NIL Then Begin
|
||||||
|
//DataSocket.Disconnect;
|
||||||
DataSocket.Free;
|
DataSocket.Free;
|
||||||
|
|
||||||
DataSocket := NIL;
|
DataSocket := NIL;
|
||||||
|
@ -160,7 +162,7 @@ Begin
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function TFTPClient.SendFile (Passive: Boolean; FileName: String) : Byte;
|
Function TFTPClient.SendFile (Passive: Boolean; LocalFile, RemoteFile: String) : Byte;
|
||||||
Var
|
Var
|
||||||
F : File;
|
F : File;
|
||||||
Buffer : Array[1..8 * 1024] of Char;
|
Buffer : Array[1..8 * 1024] of Char;
|
||||||
|
@ -169,17 +171,17 @@ Var
|
||||||
Begin
|
Begin
|
||||||
Result := ftpResFailed;
|
Result := ftpResFailed;
|
||||||
|
|
||||||
If Not FileExist(FileName) Then Exit;
|
If Not FileExist(LocalFile) Then Exit;
|
||||||
|
|
||||||
SetPassive(Passive);
|
SetPassive(Passive);
|
||||||
|
|
||||||
Client.WriteLine ('STOR ' + JustFile(FileName));
|
Client.WriteLine ('STOR ' + JustFile(RemoteFile));
|
||||||
|
|
||||||
OK := OpenDataSession;
|
OK := OpenDataSession;
|
||||||
Res := GetResponse;
|
Res := GetResponse;
|
||||||
|
|
||||||
If OK and (Res = 150) Then Begin
|
If OK and (Res = 150) Then Begin
|
||||||
Assign (F, FileName);
|
Assign (F, LocalFile);
|
||||||
|
|
||||||
If ioReset(F, 1, fmRWDN) Then Begin
|
If ioReset(F, 1, fmRWDN) Then Begin
|
||||||
Repeat
|
Repeat
|
||||||
|
@ -261,6 +263,37 @@ Begin
|
||||||
Result := SendCommand('CWD ' + Str) = 250;
|
Result := SendCommand('CWD ' + Str) = 250;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Function TFTPClient.GetDirectoryList (Passive, Change: Boolean; Str: String) : Boolean;
|
||||||
|
Begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
If Change Then Begin
|
||||||
|
Result := ChangeDirectory(Str);
|
||||||
|
|
||||||
|
If Not Result Then Exit;
|
||||||
|
End;
|
||||||
|
|
||||||
|
SetPassive(Passive);
|
||||||
|
|
||||||
|
Client.WriteLine ('NLST');
|
||||||
|
|
||||||
|
If OpenDataSession and (GetResponse = 150) Then Begin
|
||||||
|
|
||||||
|
ResponseData.Clear;
|
||||||
|
|
||||||
|
Repeat
|
||||||
|
If DataSocket.ReadLine(Str) <> -1 Then
|
||||||
|
ResponseData.Add(Str)
|
||||||
|
Else
|
||||||
|
Break;
|
||||||
|
Until Not DataSocket.Connected;
|
||||||
|
|
||||||
|
Result := GetResponse = 226;
|
||||||
|
End;
|
||||||
|
|
||||||
|
CloseDataSession;
|
||||||
|
End;
|
||||||
|
|
||||||
Procedure TFTPClient.CloseConnection;
|
Procedure TFTPClient.CloseConnection;
|
||||||
Begin
|
Begin
|
||||||
If Client.Connected Then
|
If Client.Connected Then
|
||||||
|
|
Loading…
Reference in New Issue