diff --git a/os/metadata.txt b/os/metadata.txt index 9b8e09af..ca480f15 100644 --- a/os/metadata.txt +++ b/os/metadata.txt @@ -1,5 +1,5 @@ srctype = micropython-lib type = package -version = 0.1.7 +version = 0.1.8 author = Paul Sokolovsky depends = libc, errno, stat diff --git a/os/os/__init__.py b/os/os/__init__.py index a4b11a3f..b4488327 100644 --- a/os/os/__init__.py +++ b/os/os/__init__.py @@ -21,6 +21,7 @@ rmdir_ = libc.func("i", "rmdir", "s") getcwd_ = libc.func("s", "getcwd", "si") opendir_ = libc.func("P", "opendir", "s") readdir_ = libc.func("P", "readdir", "P") +open_ = libc.func("i", "open", "sii") read_ = libc.func("i", "read", "ipi") write_ = libc.func("i", "write", "iPi") close_ = libc.func("i", "close", "i") @@ -37,6 +38,16 @@ W_OK = const(2) X_OK = const(1) F_OK = const(0) +O_ACCMODE = 0o0000003 +O_RDONLY = 0o0000000 +O_WRONLY = 0o0000001 +O_RDWR = 0o0000002 +O_CREAT = 0o0000100 +O_EXCL = 0o0000200 +O_NOCTTY = 0o0000400 +O_TRUNC = 0o0001000 +O_APPEND = 0o0002000 +O_NONBLOCK = 0o0004000 error = OSError name = "posix" @@ -132,6 +143,11 @@ def walk(top, topdown=True): if not topdown: yield top, dirs, files +def open(n, flags, mode=0o777): + r = open_(n, flags, mode) + check_error(r) + return r + def read(fd, n): buf = bytearray(n) r = read_(fd, buf, n) diff --git a/os/setup.py b/os/setup.py index a9692958..06e659fe 100644 --- a/os/setup.py +++ b/os/setup.py @@ -6,7 +6,7 @@ from setuptools import setup setup(name='micropython-os', - version='0.1.7', + version='0.1.8', description='os module for MicroPython', long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.", url='https://github.com/micropython/micropython/issues/405',