2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 POSIX function access().
10 #include <dos/filesystem.h>
12 #include <aros/debug.h>
17 /*****************************************************************************
29 Check access permissions of a file or pathname
32 path - the path of the file being checked
33 mode - the bitwise inclusive OR of the access permissions
36 W_OK - for write permission
37 R_OK - for readpermissions
38 X_OK - for execute permission
39 F_OK - Just to see whether the file exists
42 If path cannot be found or if any of the desired access
43 modes would not be granted, then a -1 value is returned;
44 otherwise a 0 value is returned.
47 Even if a process has appropriate privileges and indicates
48 success for X_OK, the file may not actually have execute
49 permission bits set. Likewise for R_OK and W_OK.
60 ******************************************************************************/
65 if (!path
) /* safety check */
71 /* how can we check whether a file exists without having read permission?? */
72 if (!mode
) mode
= R_OK
;
74 if (mode
& R_OK
) amode
|= FMF_READ
;
75 if (mode
& W_OK
) amode
|= FMF_WRITE
;
76 if (mode
& X_OK
) amode
|= FMF_EXECUTE
;
78 if (!(fh
= Lock(__path_u2a(path
), amode
)))
80 errno
= IoErr2errno(IoErr());