Im using your component to etablish a connection to a SFTP (Bulletproff FTP) and its wokring fine. But when I try to change the Create, Access and modified time of a file on the SFTP its not working.
I use the newest Secure Bridge 8.2 on Delphi XE5
After I have connected to the SFTP I try to run the following code in order to change any of the above datetime
Code: Select all
procedure TForm1.Button6Click(Sender: TObject);
var
CreateTime, AccessTime, ModifiedTime: TDatetime;
FTPCon: ThblFTPConnection;
begin
FTPCon := ThblFTPConnection.Create;
Try
CreateTime := EncodeDateTime(2018, 1, 1, 08,08,08, 0);
AccessTime := EncodeDateTime(2018, 3, 3, 12,12,12, 0);
ModifiedTime := EncodeDateTime(2018, 6, 6, 16,16,16, 0);
FTPCon.SetAttributes('/test/2018-01-15_panelists.txt', CreateTime, AccessTime, ModifiedTime);
Finally
FTPCon.Free;
end;
end;
procedure ThblFTPConnection.SetAttributes(const RemotePathFile: String;
const CreateTime, AccessTime, ModifiedTime: TDatetime);
var
Attrs: TScSFTPFileAttributes;
begin
if not Connected then
Connect;
Attrs := TScSFTPFileAttributes.Create;
Try
if CompareDateTime(AccessTime, MinDateTime) <> 0 then Begin
Attrs.AccessTime := AccessTime;
Attrs.ValidAttributes := Attrs.ValidAttributes + [aAccessTime];
end;
if CompareDateTime(ModifiedTime, MinDateTime) <> 0 then Begin
Attrs.ModifyTime := ModifiedTime;
Attrs.ValidAttributes := Attrs.ValidAttributes + [aModifyTime];
end;
if CompareDateTime(CreateTime, MinDateTime) <> 0 then Begin
Attrs.CreateTime := CreateTime;
Attrs.ValidAttributes := Attrs.ValidAttributes + [aCreateTime];
end;
FSFTPClient.SetAttributes(RemotePathFile, Attrs);
//Trying to read back what we just set and show it in a message.
FSFTPClient.RetrieveAttributes(Attrs, RemotePathFile, False, [aCreateTime, aAccessTime, aModifyTime]);
Showmessage('Set Access Date: ' + DateTimeToStr(AccessTime) + sLineBreak +
'Set Modifed Date: ' + DateTimeToStr(ModifiedTime) + sLineBreak +
'Set Create Date: ' + DateTimeToStr(CreateTime) + sLineBreak + sLineBreak +
'Get Access Date: ' + DateTimeToStr(Attrs.AccessTime) + sLineBreak +
'Get Modified Date: ' + DateTimeToStr(Attrs.ModifyTime) + sLineBreak +
'Get Create Date: ' + DateTimeToStr(Attrs.CreateTime) + sLineBreak);
Finally
Attrs.Free;
end;
end;
My Own message, but the opSettingFileAttrs is the Operation: TScSFTPOperation Enum as string.
Success: opSettingFileAttrs - System File: /test/2018-01-15_panelists.txt
Success: opClosingHandle - System File: /test/2018-01-15_panelists.txt
Is this because the SetAttributes command is not supported by the SFTP Server (Bulletproff) or Im I doing something wrong in my code ?