Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Sep : Re: Ftp server problem - D7 indy10.1.5

www.cryer.info
Managed Newsgroup Archive

Re: Ftp server problem - D7 indy10.1.5

Subject:Re: Ftp server problem - D7 indy10.1.5
Posted by:"Daniel" (..@gmail.com)
Date:19 Sep 2006 02:50:06

"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"DAniel" <DN@gmail.com> wrote in message
>news:450ecea1$1@newsgroups.borland.com...
>
>> I've changed the code to:
>
>Use this code instead:
>
>    uses
>        IdSys;
>
>    procedure TForm1.IdFTPServer1ListDirectory(ASender: TIdFTPServerContext;
>const APath: String; ADirectoryListing: TIdFTPListOutput; const ACmd,
>ASwitches: String);
>    var
>        SR: TSearchRec;
>        Item: TIdFTPListItem;
>    begin
>        if FindFirst(Sys.IncludeTrailingPathDelimiter(APath) + '*.*',
>faAnyFile, SR) = 0 then
>        try
>            repeat
>                Item := ADirectoryListing.Add;
>                Item.FileName := SR.Name;
>                Item.Size := SR.Size;
>                if (SR.Attr and faDirectory) = faDirectory then
>                    Item.ItemType := ditDirectory
>                else
>                    Item.ItemType := ditFile;
>            until FindNext(SR) <> 0;
>        finally
>            FindClose(SR);
>        end;
>    end;
>
>
>With that said, you did not answer my earlier question:
>
>    What is the actual value of Homedir and APath?
>
>> but i still get the error:
>
>You did not say anything earlier about an assertion error occuring.  You
>shuld have said so.
>
>> 450 Assertion failure (C:\Program Files\Indy 10 for Delphi
>7\Source\Protocols\IdFTPServer.pas, line 3334)
>
>There is no assertion on that line of code in the current snapshot of Indy
>10, which leads me to think that you are using an older version.  What does
>your copy of TIdFTPServer actually show for line 3334?
>
>> Could it be that i need to get the latest snapshot of indy?
>
>Maybe.
>
>
>Gambit
>
>


Thanks again for your reply.


>    What is the actual value of Homedir and APath?

Apath  - will contain whatever path the user specifies when using list command. It could be "c:\files\" or just "c:\". The "homedir" will contain, in my case, "c:\FTPServerDir\".


> What does your copy of TIdFTPServer actually show for line 3334?

Here's the list command as defined in my tidftpserver.pas file, i've marked the 3334 Error bit with "<===="
procedure TIdFTPServer.CommandLIST(ASender: TIdCommand);
var
  LStream: TIdStringList;
  LSendData : Boolean;
  LPath, LSwitches : String;
  LF : TIdFTPServerContext;

    function DeletRSwitch(const AString : String):String;
    var i : Integer;
    begin
      Result := '';
      for i := 1 to Length(AString) do
      begin
        if AString[i]<>'R' then
        begin
          Result := Result + AString[i];
        end;
      end;
    end;

begin

  LSendData := False;
  LF := TIdFTPServerContext(ASender.Context);
  with LF do begin
    if IsAuthenticated(ASender) then begin
      if FDataPortDenied then
      begin
        ASender.Reply.SetReply(425, RSFTPCantOpenData);
        Exit;
      end;
      if (not Assigned(FOnListDirectory)) and
       ((FDirFormat=ftpdfCustom) and (not Assigned(FOnCustomListDirectory))) then
      begin
        CmdNotImplemented(ASender);
        Exit;
      end;
      LStream := TIdStringList.Create;
      try
        LSwitches := '';
        LPath := ASender.UnparsedParams;
        if (LPath<>'') and (LPath[1]='-') then  {Do not Localize}
        begin
          LSwitches := Fetch(LPath);
        end;
        //we can't support recursive lists with EPLF
        if DirFormat = ftpdfEPLF then
        begin
          LSwitches :=  DeletRSwitch(LSwitches);
        end;
        ListDirectory(LF, DoProcessPath(LF, LPath), LStream, ASender.CommandHandler = FCmdHandlerList,ASender.CommandHandler.Command,LSwitches);
        LSendData := True;
      finally
        if LSendData then
        begin
          //it should be safe to assume that the FDataChannel object exists because
          //we checked it earlier
          Assert(FDataChannel<>nil); <===========3446 Error
          FDataChannel.Data := LStream;
          FDataChannel.FFtpOperation := ftpRetr;
          FDataChannel.OKReply.SetReply(226, RSFTPDataConnClosed);
          FDataChannel.ErrorReply.SetReply(426, RSFTPDataConnClosedAbnormally);
          if (FDirFormat = ftpdfEPLF) then
          begin
            ASender.Reply.SetReply(125,RSFTPDataConnToOpen);
            FDataChannel.OKReply.SetReply(226, RSFTPDataConnClosed);
          end
          else
          begin
            if TextIsSame(ASender.CommandHandler.Command, 'LIST') or (LSwitches <> '') then {do not localize}
            begin
              ASender.Reply.SetReply(125, RSFTPDataConnList);
            end
            else
            begin
              ASender.Reply.SetReply(125, RSFTPDataConnNList);
            end;
          end;
          ASender.SendReply;
          DoDataChannelOperation(ASender);
        end
        else
        begin
          Sys.FreeAndNil(LStream);
          TerminateAndFreeDataChannel;
          ASender.Reply.SetReply(426, RSFTPDataConnClosedAbnormally);
        end;
      end;
    end;
  end;
end;

I am going to try and install the latest snapshot of indy10.
Cheers

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive