function CopyFileAttributes(const sourcefile,destinationfile:string):boolean;
//Might require {$ifdef unix}baseunix{$endif} within uses
var fileinfo:{$ifdef unix}
stat;
{$endif}
{$ifdef windows}
longint;
{$endif}
begin
if (fileexists(sourcefile) and fileexists(destinationfile)) then
begin
{$ifdef unix}
exit((fpstat(sourcefile,fileinfo)=0)and(fpchmod(destinationfile,fileinfo.st_mode)=0));
{$endif}
{$ifdef windows}
fileinfo:=filegetattr(sourcefile);
if fileinfo>=0 then exit(filesetattr(destinationfile,fileinfo)=0);
{$endif}
end;
result:=false;
end;
If fpc's rtl already has such a function, you're welcome to reply it's name. If not, I'm pretty sure that you might improve this one.
In the future, I'd like a pair of cross platform functions like FileGetAttr/FileSetAttr. The fact that the pair would use data that makes sense only on the same file system, would not bother me.