File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,9 +65,22 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
6565}
6666STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_stat_obj, mod_os_stat);
6767
68+ STATIC mp_obj_t mod_os_unlink(mp_obj_t path_in) {
69+ mp_uint_t len;
70+ const char *path = mp_obj_str_get_data(path_in, &len);
71+
72+ int r = unlink(path);
73+
74+ RAISE_ERRNO(r, errno);
75+
76+ return mp_const_none;
77+ }
78+ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_unlink_obj, mod_os_unlink);
79+
6880STATIC const mp_map_elem_t mp_module_os_globals_table[] = {
6981 { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR__os) },
7082 { MP_OBJ_NEW_QSTR(MP_QSTR_stat), (mp_obj_t)&mod_os_stat_obj },
83+ { MP_OBJ_NEW_QSTR(MP_QSTR_unlink),(mp_obj_t)&mod_os_unlink_obj},
7184};
7285
7386STATIC MP_DEFINE_CONST_DICT(mp_module_os_globals, mp_module_os_globals_table);
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ Q(flush)
3636
3737Q(_os)
3838Q(stat)
39+ Q(unlink)
3940
4041Q(ffi)
4142Q(ffimod)
You can’t perform that action at this time.
0 commit comments