aboutsummaryrefslogtreecommitdiff
path: root/extmod/vfs_fat.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-07 13:44:55 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-07 13:44:55 +1100
commit620c4c32bf1ad3123d0b5a326fede444149651c3 (patch)
treeb493a7488af0ff6f1d91cf4009a7c8fc804fc3fe /extmod/vfs_fat.c
parent3a0a7717304cc34a4d6ef55f767666c918c185b5 (diff)
extmod/vfs_fat: Use mp_raise_OSError helper function.
Diffstat (limited to 'extmod/vfs_fat.c')
-rw-r--r--extmod/vfs_fat.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c
index 2e74f19d6..3a17533e4 100644
--- a/extmod/vfs_fat.c
+++ b/extmod/vfs_fat.c
@@ -84,8 +84,7 @@ STATIC mp_obj_t fat_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) {
if (res == FR_OK) {
return mp_const_none;
} else {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError,
- MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_remove_obj, fat_vfs_remove);
@@ -106,8 +105,7 @@ STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_
if (res == FR_OK) {
return mp_const_none;
} else {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError,
- MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
}
@@ -120,8 +118,7 @@ STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) {
if (res == FR_OK) {
return mp_const_none;
} else {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError,
- MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_mkdir_obj, fat_vfs_mkdir);
@@ -139,8 +136,7 @@ STATIC mp_obj_t fat_vfs_chdir(mp_obj_t vfs_in, mp_obj_t path_in) {
}
if (res != FR_OK) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError,
- MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
return mp_const_none;
@@ -154,7 +150,7 @@ STATIC mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) {
FRESULT res = f_getcwd(buf, sizeof buf);
if (res != FR_OK) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
return mp_obj_new_str(buf, strlen(buf), false);
@@ -215,8 +211,7 @@ STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
res = f_stat(path, &fno);
}
if (res != FR_OK) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError,
- MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
}
@@ -259,8 +254,7 @@ STATIC mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) {
DWORD nclst;
FRESULT res = f_getfree(path, &nclst, &fatfs);
if (FR_OK != res) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError,
- MP_OBJ_NEW_SMALL_INT(fresult_to_errno_table[res])));
+ mp_raise_OSError(fresult_to_errno_table[res]);
}
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));