os: Add access().

pull/118/head
Paul Sokolovsky 2014-05-14 17:45:38 +03:00
rodzic d75ad4867d
commit b5a6cbb4ae
2 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -12,12 +12,18 @@ readdir_ = libc.func("P", "readdir", "P")
read_ = libc.func("i", "read", "ipi")
write_ = libc.func("i", "write", "iPi")
close_ = libc.func("i", "close", "i")
access_ = libc.func("i", "access", "si")
fork_ = libc.func("i", "fork", "")
pipe_ = libc.func("i", "pipe", "p")
_exit_ = libc.func("v", "_exit", "i")
getpid_ = libc.func("i", "getpid", "")
waitpid_ = libc.func("i", "waitpid", "ipi")
R_OK = const(4)
W_OK = const(2)
X_OK = const(1)
F_OK = const(0)
def check_error(ret):
if ret == -1:
@ -61,6 +67,8 @@ def close(fd):
check_error(r)
return r
def access(path, mode):
return access_(path, mode) == 0
def fork():
r = fork_()

Wyświetl plik

@ -0,0 +1,5 @@
import os
assert os.access("test_filestat.py", os.F_OK) == True
assert os.access("test_filestat.py-not", os.F_OK) == False