From 484bfdf0a7dc73179ac85838cd0cfdaf9eb4e7da Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Mon, 16 Sep 2013 16:31:33 -0400 Subject: [PATCH] A38 work --- mdl/m_tcp_client_ftp.pas | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mdl/m_tcp_client_ftp.pas b/mdl/m_tcp_client_ftp.pas index 712e881..2034b69 100644 --- a/mdl/m_tcp_client_ftp.pas +++ b/mdl/m_tcp_client_ftp.pas @@ -5,10 +5,14 @@ Unit m_Tcp_Client_FTP; Interface Uses -// SysUtils, //wordrec m_io_Sockets, m_Tcp_Client; +Const + ftpResOK = 0; + ftpResFailed = 1; + ftpResBadData = 2; + Type WordRec = Record Lo : Byte; @@ -30,8 +34,8 @@ Type Function OpenConnection (HostName: String) : Boolean; Function Authenticate (Login, Password: String) : Boolean; Function ChangeDirectory (Str: String) : Boolean; - Function SendFile (Passive: Boolean; FileName: String) : Boolean; - Function GetFile (Passive: Boolean; FileName: String) : Boolean; + Function SendFile (Passive: Boolean; FileName: String) : Byte; + Function GetFile (Passive: Boolean; FileName: String) : Byte; Procedure CloseConnection; End; @@ -41,9 +45,6 @@ Uses m_FileIO, m_Strings; -Const - ftpDefaultDataPort = 20; - Constructor TFTPClient.Create (NetI: String); Begin Inherited Create(NetI); @@ -158,14 +159,14 @@ Begin End; End; -Function TFTPClient.SendFile (Passive: Boolean; FileName: String) : Boolean; +Function TFTPClient.SendFile (Passive: Boolean; FileName: String) : Byte; Var F : File; Buffer : Array[1..8 * 1024] of Char; Res : LongInt; OK : Boolean; Begin - Result := False; + Result := ftpResFailed; If Not FileExist(FileName) Then Exit; @@ -193,25 +194,23 @@ Begin CloseDataSession; - Result := GetResponse = 226; + If GetResponse = 226 Then + Result := ftpResOK; End Else Begin -// If IsPassive Then -// WriteLn ('DEBUG unable to connect to FTP server for data session') -// Else -// WriteLn ('DEBUG unable to establish data session on port ', DataPort); + Result := ftpResBadData; CloseDataSession; End; End; -Function TFTPClient.GetFile (Passive: Boolean; FileName: String) : Boolean; +Function TFTPClient.GetFile (Passive: Boolean; FileName: String) : Byte; Var F : File; Res : LongInt; - Buffer : Array[1..8*1024] of Char; + Buffer : Array[1..8 * 1024] of Char; OK : Boolean; Begin - Result := False; + Result := ftpResFailed; If FileExist(FileName) Then Exit; @@ -239,12 +238,10 @@ Begin CloseDataSession; - Result := GetResponse = 226; + If GetResponse = 226 Then + Result := ftpResOK; End Else Begin -// If IsPassive Then -// WriteLn ('DEBUG unable to connect to FTP server for data session') -// Else -// WriteLn ('DEBUG unable to establish data session on port ', DataPort); + Result := ftpResBadData; CloseDataSession; End;