Skip to content

Commit 27da05f

Browse files
committed
os: Add chdir(), rename().
1 parent 4e3154b commit 27da05f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

os/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
srctype = micropython-lib
22
type = package
3-
version = 0.1.3
3+
version = 0.1.4
44
author = Paul Sokolovsky
55
depends = libc

os/os/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
libc = _libc.get()
1414

1515
errno_ = libc.var("i", "errno")
16+
chdir_ = libc.func("i", "chdir", "s")
1617
mkdir_ = libc.func("i", "mkdir", "si")
18+
rename_ = libc.func("i", "rename", "ss")
1719
unlink_ = libc.func("i", "unlink", "s")
1820
rmdir_ = libc.func("i", "rmdir", "s")
1921
getwd_ = libc.func("s", "getwd", "s")
@@ -60,6 +62,10 @@ def mkdir(name, mode=0o777):
6062
e = mkdir_(name, mode)
6163
check_error(e)
6264

65+
def rename(old, new):
66+
e = rename_(old, new)
67+
check_error(e)
68+
6369
def unlink(name):
6470
e = unlink_(name)
6571
check_error(e)
@@ -145,6 +151,10 @@ def close(fd):
145151
def access(path, mode):
146152
return access_(path, mode) == 0
147153

154+
def chdir(dir):
155+
r = chdir_(dir)
156+
check_error(r)
157+
148158
def fork():
149159
r = fork_()
150160
check_error(r)

os/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
setup(name='micropython-os',
9-
version='0.1.3',
9+
version='0.1.4',
1010
description='os module for MicroPython',
1111
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.",
1212
url='https://github.com/micropython/micropython/issues/405',

0 commit comments

Comments
 (0)