hello
Is there anybody has worked with STAT_IRWXG ?
http://www.freepascal.org/docs-html/rtl/oldlinux/index-2.html
I need infos in order to get a function that get file permissions on linux system (like 0777, 0755...)
best regards

Mailing lists / fpc-pascal / 2007-04
3 messages · 2 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
hello
Is there anybody has worked with STAT_IRWXG ?
http://www.freepascal.org/docs-html/rtl/oldlinux/index-2.html
I need infos in order to get a function that get file permissions on linux system (like 0777, 0755...)
best regards
Is there anybody has worked with STAT_IRWXG ? http://www.freepascal.org/docs-html/rtl/oldlinux/index-2.html
That is a legacy api. Better use Baseunix:
I need infos in order to get a function that get file permissions on linux system (like 0777, 0755...)
http://www.freepascal.org/docs-html/rtl/baseunix/fpaccess.html
or via stat:
http://www.freepascal.org/docs-html/rtl/baseunix/fpstat.html
Note that you can make octal values using the & notation.
E.g.
var i : integer;
begin
i:=&770;
writeln(i);
end.Thanks marco for the way
i have copy the example , but how can i convert "info.st_mode" in human readable mask (0777, 0755...)
For example, a file in 0755 mask is 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.