Dear

I need to return the correct mask of chmod permission, in this case,
i have copy the FPC example , but i cannot convert "info.st_mode" in human readable mask (0777, 0755...)

For example, with a file in 0755 mask the function return 16877 value in info.st_mode.

best regards


unit base_unix;


{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils,variants, Linux,BaseUnix,IniFiles,strutils;

type
Tunix=class


private


public
 procedure Free;
 constructor Create;
 function get_file_permission(path:string):string;

END;

implementation

constructor Tunix.Create;
begin

end;
//##############################################################################
procedure Tunix.Free;
begin

end;

function Tunix.get_file_permission(path:string):string;
var
s:string;
info : stat;
i:Integer;
begin
fpstat (path,info);
writeln;


writeln ('Result of fstat on file');
writeln ('Inode   : ',info.st_ino);
writeln ('Mode    : ',info.st_mode);
writeln ('nlink   : ',info.st_nlink);
writeln ('uid     : ',info.st_uid);
writeln ('gid     : ',info.st_gid);
writeln ('rdev    : ',info.st_rdev);
writeln ('Size    : ',info.st_size);
writeln ('Blksize : ',info.st_blksize);
writeln ('Blocks  : ',info.st_blocks);
writeln ('atime   : ',info.st_atime);
writeln ('mtime   : ',info.st_mtime);
writeln ('ctime   : ',info.st_ctime);
end;
//##############################################################################


end.
--
David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to