[Overview][Constants][Types][Procedures and functions][Variables] Reference for unit 'oldlinux' (#rtl)

Access

Check file access

Declaration

Source position: oldlinux.pp line 1400

function Access(

  Path: PathStr;

  mode: Integer

):Boolean;

Description

Accesstests user's access rights on the specified file. Modeis a mask existing of one or more of the following:

R_OK
User has read rights.
W_OK
User has write rights.
X_OK
User has execute rights.
F_OK
File exists.

The test is done with the real user ID, instead of the effective user ID. If access is denied, or an error occurred, Falseis returned.

Errors

LinuxErroris used to report errors:

sys_eaccess
The requested access is denied, either to the file or one of the directories in its path.
sys_einval
Modewas incorrect.
sys_enoent
A directory component in Pathdoesn't exist or is a dangling symbolic link.
sys_enotdir
A directory component in Pathis not a directory.
sys_enomem
Insufficient kernel memory.
sys_eloop
Pathhas a circular symbolic link.

See also

Chown

  

Change owner of file

Chmod

  

Change file permission bits

Example

Program Example26;

{ Program to demonstrate the Access function. }

Uses oldlinux;

begin
  if Access ('/etc/passwd',W_OK) then
    begin
    Writeln ('Better check your system.');
    Writeln ('I can write to the /etc/passwd file !');
    end;
end.