TidFtpServer OnCrcFile problem

Giganews Newsgroups
Subject: TidFtpServer OnCrcFile problem
Posted by:  Pascal (pcoen…@telenetdotbe)
Date: Wed, 10 Dec 2008

Hello all,

I'm having a problem with the IdFtpServer OnCrcFile event. If the
filename contains spaces (example: My Test File.txt) then the AFileName
const of the OnCrcFile result as My. It must be something in the
following code part:

The LBuf:= ASender.UnparsedParams result is correct

procedure TIdFTPServer.CommandCheckSum(ASender: TIdCommand);
const
  HashTypes: array[0..2] of TIdHashClass = (TIdHashCRC32,
TIdHashMessageDigest5, TIdHashSHA1);
var
  LCalcStream : TStream;
  LFileName, LCheckSum, LBuf : String;
  LBeginPos, LEndPos : Int64;
  LContext : TIdFTPServerContext;
  LHashIdx: Integer;
begin
  if Assigned(FOnCRCFile) or Assigned(FTPFileSystem) then
  begin
    LContext := TIdFTPServerContext(ASender.Context);
    if LContext.IsAuthenticated(ASender) then
    begin
      LBuf := ASender.UnparsedParams;
      if Pos('"', LBuf) > 0 then {do not localize}
      begin
        Fetch(LBuf, '"'); {do not localize}
        LFileName := Fetch(LBuf, '"'); {do not localize}
      end else begin
        LFileName := Fetch(LBuf);
      end;
      if LFileName = '' then
      begin
        ASender.Reply.SetReply(501, IndyFormat(RSFTPParamError,
[ASender.CommandHandler.Command]));
        Exit;
      end;
      LBuf := Trim(LBuf);
      LBeginPos := IndyStrToInt(Fetch(LBuf), 0);
      LEndPos := IndyStrToInt(Fetch(LBuf), 0);
      LCalcStream := nil;
      LFileName := DoProcessPath(LContext, LFileName);

Best Regards,
Pascal
--

Replies