ftpserver small code adjust for cdup

Giganews Newsgroups
Subject: ftpserver small code adjust for cdup
Posted by:  Martin B (xsmar…@hotmail.com)
Date: Fri, 16 Jul 2004

I dont know if this is the correct place to post this but here goes

I noticed that with a client that cdup's to the root dir gets ../ as the
path instead of /
so thinking that it wasnt quiet correct I decided to fix that little thing
and put in one extra line into the source

code as follows

procedure TIdFTPServer.CommandCDUP(ASender: TIdCommand);
var
  s: string;
  LF : TIdFTPServerContext;
begin
  LF := TIdFTPServerContext(ASender.Context);
    if LF.IsAuthenticated(ASender) then begin
        s := CDUPDir(LF);
        if Assigned(FOnChangeDirectory) or Assigned(FFTPFileSystem) then
begin
          DoOnChangeDirectory(LF, s);
          //added xsm
          if s = '../' then s := '/';
          // finish add xsm
          LF.FCurrentDir := s;
          ASender.Reply.SetReply(250, Format(RSFTPCurrentDirectoryIs,
[LF.FCurrentDir]));
        end else begin
          CmdNotImplemented(ASender);
        end;
    end;
end;

Replies