Pascal / BaseUnix / FpAccess
» FpAccess, FpAlarm, FpChdir, FpChmod, FpChown, FpClose, FpClosedir, FpDup, FpDup2, FpExecv, FpExecve, FpExit, FpFcntl, pfdfillset, fpFD_CLR, fpFD_ISSET, fpFD_SET, fpFD_ZERO, FpFork, FPFStat, FpFtruncate, FpGetcwd, FpGetegid, FpGetEnv, fpgeterrno, FpGeteuid, FpGetgid, FpGetgroups, FpGetpgrp, FpGetpid, FpGetppid, fpGetPriority, FpGetuid, FpIOCtl, FpKill, FpLink, FpLseek, fpLstat, FpMkdir, FpMkfifo, Fpmmap, Fpmunmap, FpNanoSleep, fpNice, FpOpen, FpOpendir, FpPause, FpPipe, FpRead, FpReaddir, fpReadLink, FpRename, FpRmdir, fpSelect, fpseterrno, FpSetgid, fpSetPriority, FpSetsid, fpsettimeofday, FpSetuid,
Funcion: FpAccess()
Sintaxis:
function FpAccess(
 
  pathname: pChar;
 
  aMode: cInt
 
):cInt;
 
function FpAccess(
 
  path

Descripcion: Checa el acceso a un archivo.

FpAccess prueba los derechos de acceso a los usuarios en el archivo especificado. Mode es una mascara existente de uno de los muchos existentes siguientes:

R_OK --> El usuario tiene "read rights"
W_OK --> El usuario tiene "write rights"
X_OK --> El usuario tiene "Execute rights"
F_OK --> Archivo existe

La prueba es hecha con el ID real del usuario, en lugar de el ID efectivo del usuario. Si el usuario tiene "requested rights", regreza zero. Si el acceso es negado, o un error ha ocurrido, un valor distinto de zero es regrezado.

Errores
La información extendida del error se puede recuperar usando la funcion 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.
Ejemplo:
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.

Librerias Pascal

Libreria crt - CRT - Pantalla y teclado del PASCAL de Turbo que maneja la unidad
Libreria dos - DOS - Interface Turbo Pascal MS-DOS
Libreria Graph - Unidad para manipular los graficos de la pantalla compatible con TP
Libreria Objects - Objetos basicos compatible con TP
Libreria math - Rutinas adicionales matematicas
Libreria Printer - Provee de acceso a la impresora
Libreria strings - Rutinas para el manejo de cadenas
Libreria BaseUnix - Funcionalidad Basica de Linux
Libreria System - Manejo de Archivos - Funciones para la manipulacion de archivos en Pascal