Skip to content

Commit

Permalink
[component/python/os] add chdir and os.name
Browse files Browse the repository at this point in the history
  • Loading branch information
versaloon committed Sep 8, 2023
1 parent 819fd23 commit 308d806
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions source/component/script/python/module/os/vsf_python_module_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ vsf_pyal_module_func_init_imp(os)
vsf_pyal_module_add_int(os, "O_APPEND", O_APPEND);
vsf_pyal_module_add_int(os, "O_CREAT", O_CREAT);

struct utsname name;
uname(&utsname);
vsf_pyal_module_add_str(os, "name", name.sysname);

environ_dict = vsf_pyal_newdict();
vsf_pyal_module_add_obj(os, "environ", environ_dict);
#else
Expand Down Expand Up @@ -181,6 +185,15 @@ vsf_pyal_module_func_fix_imp(os, rmdir, VSF_PYAL_MODULE_FUNCARG_OBJ_1, vsf_pyal_
vsf_pyal_func_void_return();
}

vsf_pyal_module_func_fix_imp(os, chdir, VSF_PYAL_MODULE_FUNCARG_OBJ_1, vsf_pyal_func_void_return_t, vsf_pyal_funcarg_strobj path)
{
char *path_str = vsf_pyal_funcarg_strobj_get_str(path);
if (chdir((const char *)path_str) < 0) {
vsf_pyal_raise("fail to chdir(%s)\n", path_str);
}
vsf_pyal_func_void_return();
}

vsf_pyal_module_func_fix_imp(os, rename, VSF_PYAL_MODULE_FUNCARG_OBJ_2, vsf_pyal_func_void_return_t, vsf_pyal_funcarg_strobj old, vsf_pyal_funcarg_strobj new)
{
char *path_old_str = vsf_pyal_funcarg_strobj_get_str(old);
Expand Down Expand Up @@ -360,6 +373,7 @@ vsf_pyal_module(os,
vsf_pyal_module_func(os, mkdir),
vsf_pyal_module_func(os, makedirs),
vsf_pyal_module_func(os, rmdir),
vsf_pyal_module_func(os, chdir),
vsf_pyal_module_func(os, rename),
vsf_pyal_module_func(os, remove),
vsf_pyal_module_func(os, open),
Expand Down

0 comments on commit 308d806

Please sign in to comment.