Mono Class Library: Mono.Unix.Native.Syscall Overview | MembersMono.Unix.Native.Syscall.access Method |
Checks whether the calling task has the necessary access rights to perform operations specified by mode on the file pathname. AccessMode is a mask consisting of one or more of the values R_OK, W_OK, X_OK and F_OK which respectively test if the taks can read, write, execute or test if the file exists. [Edit]
|
On success, zero is returned. On error, -1 is returned and Stdlib.GetLastError returns the translated error.
Usage
Access to the file is denied if:
[Edit]
Error Details Errno.ENOTDIR A component of the path prefix is not a directory.
Errno.ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.
Errno.ENOENT The named file does not exist.
Errno.ELOOP Too many symbolic links were encountered in translating the pathname.
Errno.EROFS Write access is requested for a file on a read-only file system.
Errno.ETXTBSY Write access is requested for a pure procedure (shared text) file presently being executed.
Errno.EACCES Permission bits of the file mode do not permit the requested access, or search permission is denied on a component of the path prefix.
Errno.EFAULT The path argument points outside the process's allocated address space.
Errno.EIO An I/O error occurred while reading from or writing to the file system.
The access() and eaccess() system calls check the accessibility of the file named by the path argument for the access permissions indicated by the mode argument. The value of mode is either the bitwise-inclusive OR of the access permissions to be checked ( AccessModes.R_OK for read permission, AccessModes.W_OK for write permission, and AccessModes.X_OK for execute/search permission), or the existence test AccessModes.F_OK .
For additional information, see the "File Access Permission" section of Syscall.intro(2) .
The eaccess() system call uses the effective user ID and the group access list to authorize the request; the access() system call uses the real user ID in place of the effective user ID, the real group ID in place of the effective group ID, and the rest of the group access list.
Even if a process's real or effective user has appropriate privileges and indicates success for AccessModes.X_OK , the file may not actually have execute permission bits set. Likewise for AccessModes.R_OK and AccessModes.W_OK .
[Edit]
Namespace: Mono.Unix.Native
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0