The mode
value can be the exclusive or of the following values
- 0
- test for existence.
- 1
- test for execute permission.
- 2
- test for write permission.
- 4
- test for read permission.
unix
Permission will be computed for real user ID and real group ID (rather
than the effective IDs).
windows
This function does uses the C function _access
in
msvcrt.dll, but was written using Win32 API functions.
Windows does not have the concept of an executable file, so
this function regards directories and files with extension
.exe, .bat, .cmd and .com as executable.
(system
and Sys.which
make the same assumption.)
UTF-8-encoded file names not valid in the current locale can be used.
Please note that it is not a good idea to use this function to test
before trying to open a file. On a multi-tasking system, it is
possible that the accessibility of a file will change between the time
you call file.access()
and the time you try to open the file.
It is better to wrap file open attempts in try
.