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

FpAccess

Check file access

Declaration

Source position: bunxh.inc line 82

function FpAccess(

  pathname: PChar;

  aMode: cint

):cint;

function FpAccess(

  const pathname: RawByteString;

  aMode: cint

):cint;

Description

FpAccess tests user's access rights on the specified file. Mode is 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 the user has the requested rights, zero is returned. If access is denied, or an error occurred, a nonzero value is returned.

Errors

Extended error information can be retrieved using fpGetErrno.

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

See also

FpChown

  

Change owner of file

FpChmod

  

Change file permission bits

Example

Program Example26;

{ Program to demonstrate the Access function. }

Uses BaseUnix;

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

Documentation generated on: Mar 17 2017