Re: TIdFTP.List Question

Giganews Newsgroups
Subject: Re: TIdFTP.List Question
Posted by:  Pascal (pcoen…@telenetdotbe)
Date: Sun, 7 Jun 2009

Pascal wrote:

>
> Hi,
>
> A question about the TIdFTP.List procedure:
>
> - I'm using TIdLogDebug for debugging.
> - ADetails = False so I'm not using ExtListDir(ADest)
> - I've been debugging this for a couple of hours and the part were the
> transfertype is put into ASCII before the actual list command and
> afterwards is restored to ftBinary if the original type wasn't ASCII
> isn't working (I think, I'm quite sure).
> It's really strange. It only works correct if I force it using
> SendTranferType.
>
> procedure TIdFTP.List(ADest: TStrings; const ASpecifier: string = '';
> ADetails: Boolean = True);      {do not localize}
> var
>  LDest: TMemoryStream;
>  LTrans : TIdFTPTransferType;
> begin
>  if ADetails and UseMLIS and FCanUseMLS then begin
>    ExtListDir(ADest);
>    Exit;
>  end;
>  //Note that for LIST, it might be best to put the connection in
> ASCII  //mode because some old servers such as TOPS20 might require
> this.  We  //restore it
>  //if the original mode was not ASCII.  It's a good idea to do this
>  //anyway
>  //because some clients still do this such as WS_FTP Pro and
>  //Microsoft's FTP Client.
>  LTrans := TransferType;
>  if LTrans <> ftASCII then begin
>    Self.TransferType := ftASCII;
>    --> After this force it using SendTranferType
>  end;
>  try
>
>  <snip>
>
>  finally
>    if LTrans <> ftASCII then begin
>      TransferType := LTrans;
>      --> After this force it using SendTranferType
>    end;
>  end;
> end;
>
> Regards,
> Pascal

Ok, did some more tests. I want to convince you.

- Using snap version Indy 10
- Debugging TIdFtp.list procedure
- Problem found in procedure TIdFTP.SetTransferType(AValue:
TIdFTPTransferType);
- Changed the position of FTransferType := AValue;
- Now the change to ASCII and back to Binary for the IdFtp.List
procedure works fine.

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

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;

Regards,
Pascal

--

Replies

In response to

TIdFTP.List Question posted by Pascal on Sat, 6 Jun 2009