Jump to content
AllanF

64 Bit TSslFtpServer not Renaming a File

Recommended Posts

On Server Side I have been successfully using TSslFtpServer (Delphi Seattle) with IcsHosts for SSL

From Client Side I PUT a File , Check Size after Copy & Finally Rename the File.

All this has worked fine for years.

 

My Server Side Exe was 32 Bit. Now I want to make it 64Bit Exe.

From Client side Copy takes place , Size checking takes place but Rename does not happen.

I get the error

450 File '/c:/Sample/Abc.txt' can't be renamed

 

64 Bit works fine without SSL

Share this post


Link to post

Easiest solution is to put a breakpoint in the CommandRNTO procedure and step through under the debugger to see which statement fails. There is nothing obvious that would fail on Win64.

 

Angus

 

Share this post


Link to post

The function returns True even though pointing to a files that does not exist

function DirExists(const Dir : String) : Boolean;    
     // Dir = 'c:\23000\Pqr.txt'
var
    Res : DWORD;
begin
    Res := GetFileAttributes(PChar(Dir));
        // Res = 4294967295 
    Result := (Res <> INVALID_HANDLE_VALUE) and
              ((Res and FILE_ATTRIBUTE_DIRECTORY) <> 0);
        // Res and FILE_ATTRIBUTE_DIRECTORY   = 16

// (Res <> INVALID_HANDLE_VALUE) and ((Res and FILE_ATTRIBUTE_DIRECTORY) <> 0)

// Though having the same value this line return True in 64Bitness and False in 32Bitness
end;

procedure TFtpServer.CommandRNTO(
...
    if FileExists(FileName) or DirExists(Filename) then 

          Answer =    '553 ''/c:/23000/Pqr.txt'': file already exists.'

Edited by AllanF

Share this post


Link to post

Thanks, I'll try and test this next week.  The API is documented as returning INVALID_FILE_ATTRIBUTES for failure, which we assume is -1, but maybe it's not.

 

Angus

 

 

 

Share this post


Link to post

The quick solution is to replace DirExists with SysUtils.DirectoryExists which is available in Unicode compilers, and which is already used in OverbyteUtils for IcsDirExistsW. I'll fix this in SVN shortly.

 

Angus

 

  • Thanks 1

Share this post


Link to post

 

I did changes as you mentioned and it is working now.

Thank You.

 

 

unit OverbyteIcsFtpSrv;

...

...

 


function DirExists(const Dir : String) : Boolean;                 { V1.52 AG}
{ INVALID_HANDLE_VALUE = INVALID_FILE_ATTRIBUTES = DWORD(-1) }
{$IFDEF MSWINDOWS}
var
    Res : DWORD;
begin
    Result := {$IFDEF RTL_NAMESPACES}System.{$ENDIF}SysUtils.DirectoryExists(UnicodeString(Dir));
   exit ;

//    Res := GetFileAttributes(PChar(Dir));
  //  Result := (Res <> INVALID_HANDLE_VALUE) and
    //          ((Res and FILE_ATTRIBUTE_DIRECTORY) <> 0);
end;
{$ENDIF}
{$IFDEF POSIX}
begin
    Result := System.SysUtils.DirectoryExists(Dir);  { V8.50 }
end;
{$ENDIF}

Share this post


Link to post

Good, as ICS has developed over 20 years there are local functions like DirExists in various units, often duplicated and not always kept up to date, which I'm slowly concentrating in OverbyteUtils.

 

Angus

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×