kopia lustrzana https://github.com/micropython/micropython-lib
Add very basic implementation of os and fcntl modules for unix port.
Using ffi module. Both offer just 1-2 initial functions so far.asyncio-segfault
rodzic
e71f9f41c4
commit
27ec4eb700
|
@ -0,0 +1,23 @@
|
||||||
|
import ffi
|
||||||
|
|
||||||
|
|
||||||
|
libc = ffi.open("libc.so.6")
|
||||||
|
|
||||||
|
fcntl_l = libc.func("i", "fcntl", "iil")
|
||||||
|
fcntl_s = libc.func("i", "fcntl", "iis")
|
||||||
|
ioctl_l = libc.func("i", "ioctl", "iil")
|
||||||
|
ioctl_s = libc.func("i", "ioctl", "iis")
|
||||||
|
|
||||||
|
|
||||||
|
def fcntl(fd, op, arg):
|
||||||
|
if type(arg) is int:
|
||||||
|
return fcntl_l(fd, op, arg)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
def ioctl(fd, op, arg):
|
||||||
|
if type(arg) is int:
|
||||||
|
return ioctl_l(fd, op, arg)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
|
@ -0,0 +1,14 @@
|
||||||
|
import ffi
|
||||||
|
|
||||||
|
|
||||||
|
libc = ffi.open("libc.so.6")
|
||||||
|
|
||||||
|
errno = libc.var("i", "errno")
|
||||||
|
mkdir_ = libc.func("i", "mkdir", "si")
|
||||||
|
|
||||||
|
|
||||||
|
def mkdir(name, mode=0o777):
|
||||||
|
e = mkdir_(name, mode)
|
||||||
|
if not e:
|
||||||
|
return
|
||||||
|
raise OSError(errno.get())
|
Ładowanie…
Reference in New Issue