mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
up
This commit is contained in:
parent
e5c96c2732
commit
d954e74188
@ -282,6 +282,32 @@ def open(path, mode='r'):
|
||||
return FileIO(path, mode)
|
||||
)";
|
||||
|
||||
const char* __OS_CODE = R"(
|
||||
def listdir(path):
|
||||
assert type(path) is str
|
||||
return jsonrpc("os.listdir", [path])
|
||||
|
||||
def mkdir(path):
|
||||
assert type(path) is str
|
||||
return jsonrpc("os.mkdir", [path])
|
||||
|
||||
def rmdir(path):
|
||||
assert type(path) is str
|
||||
return jsonrpc("os.rmdir", [path])
|
||||
|
||||
def remove(path):
|
||||
assert type(path) is str
|
||||
return jsonrpc("os.remove", [path])
|
||||
|
||||
path = object()
|
||||
|
||||
def __path4exists(path):
|
||||
assert type(path) is str
|
||||
return jsonrpc("os.path.exists", [path])
|
||||
path.exists = __path4exists
|
||||
del __path4exists
|
||||
)";
|
||||
|
||||
const char* __RANDOM_CODE = R"(
|
||||
import time as _time
|
||||
|
||||
|
@ -769,6 +769,7 @@ extern "C" {
|
||||
if(code == nullptr) exit(1);
|
||||
vm->_exec(code, vm->builtins, {});
|
||||
pkpy_vm_add_module(vm, "random", __RANDOM_CODE);
|
||||
pkpy_vm_add_module(vm, "os", __OS_CODE);
|
||||
}
|
||||
|
||||
__EXPORT
|
||||
|
Loading…
x
Reference in New Issue
Block a user