Page 1 of 1

How to read Linux File attributes?

Posted: Sat Apr 18, 2020 9:17 am
by Zinn
Another question is: How to read the attributes of a Linux file or Linux directory from BlackBox?
Is there a call available via the Lin library? Where can I find a description or an explanation about the Lin library?
- Helmut

Re: How to read Linux File attributes?

Posted: Wed Apr 22, 2020 3:12 pm
by Ivan Denisov
I got some copypaste from HostFiles. Information about libc library you can find in the Internet documentation for Linux.

Code: Select all

MODULE DemoRun;
	IMPORT  Log, Libc := LinLibc, HostFiles, Strings;
	
	TYPE
		ShortName = ARRAY 260 * 4 OF SHORTCHAR;
	
	PROCEDURE Stat*;
	CONST
		read = 8;
		write = 7;
		execute = 6;
		file = 15;
		
		VAR s: ShortName; ok1, res: INTEGER; buf: Libc.stat_t;
	BEGIN
		Strings.StringToUtf8('/home/dia/blackbox/test', s, ok1);
		res := Libc.__xstat(Libc._STAT_VER_LINUX, s, buf); (* macro expansion of "stat" *)
		Log.String("is directory "); Log.Bool(~ (file IN buf.st_mode)); Log.Ln;
		Log.String("all bits "); Log.Set(buf.st_mode); Log.Ln;
		
	END Stat;

END DemoRun.