IdFtp questions

Giganews Newsgroups
Subject: IdFtp questions
Posted by:  Pascal (pcoen…@telenetdotbe)
Date: Thu, 4 Jun 2009

Hi,

Some questions.

Q1: TIdFTP.List(ADest: TStrings; const ASpecifier: string = '';
ADetails: Boolean = True);      {do not localize}
//Note that for LIST, it might be best to put the connection in ASCII
  LTrans := TransferType;
  if LTrans <> ftASCII then begin
    Self.TransferType := ftASCII;

Why is this only done for List and not for 'ExtListDir(ADest)'?

Q2: TIdFTP.SendTransferType

procedure TIdFTP.SendTransferType;
var
  s: string;
begin
  s := '';
  case TransferType of
    ftAscii: s := 'A';      {do not localize}
    ftBinary: s := 'I';    {do not localize}
  end;
  if s = '' then begin
    raise
EIdFTPUnsupportedTransferType.Create(RSFTPUnsupportedTransferType);
  end;
  SendCmd('TYPE ' + s, 200); {do not localize}
end;

Why Case TransferType instead of Case FTransferType. If you dyn create
this IdFtp component at runtime and you don't explicitly set the
TransferType property then the SendTransferType at connect and login
won't do anything because TransferType is empty.

Q3: procedure TIdFTP.SetTransferType

procedure TIdFTP.SetTransferType(AValue: TIdFTPTransferType);
begin
  if AValue <> FTransferType then begin
    if not Assigned(FDataChannel) then begin
      if Connected then begin
        SendTransferType;
      end;
      FTransferType := AValue;
    end;
  end;
end;

Isn't it better to remove the 'if AValue <> FTransferType' part. This
way we could resend the Type command (even if it's the same). The
reason: Some FTP servers do ASCII for the LIST command (using the
ExtListDir(ADest) procedure) but stay in ASCII even if I requested
Binary at connection (and login).

--

Greetings,
Pascal

Replies