|
|
@ -89,10 +89,27 @@ STATIC mp_obj_t fat_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) { |
|
|
|
} |
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_remove_obj, fat_vfs_remove); |
|
|
|
|
|
|
|
STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) { |
|
|
|
(void)vfs_in; |
|
|
|
const char *path = mp_obj_str_get_str(path_o); |
|
|
|
FRESULT res = f_mkdir(path); |
|
|
|
switch (res) { |
|
|
|
case FR_OK: |
|
|
|
return mp_const_none; |
|
|
|
case FR_EXIST: |
|
|
|
// TODO should be FileExistsError
|
|
|
|
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "File exists: '%s'", path)); |
|
|
|
default: |
|
|
|
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "Error creating directory '%s'", path)); |
|
|
|
} |
|
|
|
} |
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_mkdir_obj, fat_vfs_mkdir); |
|
|
|
|
|
|
|
STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = { |
|
|
|
{ MP_ROM_QSTR(MP_QSTR_mkfs), MP_ROM_PTR(&fat_vfs_mkfs_obj) }, |
|
|
|
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&fat_vfs_open_obj) }, |
|
|
|
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&fat_vfs_listdir_obj) }, |
|
|
|
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&fat_vfs_mkdir_obj) }, |
|
|
|
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&fat_vfs_remove_obj) }, |
|
|
|
}; |
|
|
|
STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table); |
|
|
|