factor out storage_object_from_path
This commit is contained in:
parent
1eba580443
commit
968763aa1d
@ -109,19 +109,15 @@ void common_hal_storage_umount_object(mp_obj_t vfs_obj) {
|
|||||||
mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL);
|
mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_storage_umount_path(const char* mount_path) {
|
STATIC mp_obj_t storage_object_from_path(const char* mount_path) {
|
||||||
// remove vfs from the mount table
|
|
||||||
mp_obj_t *vfs_obj = NULL;
|
|
||||||
for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
|
for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
|
||||||
if (strcmp(mount_path, (*vfsp)->str) == 0) {
|
if (strcmp(mount_path, (*vfsp)->str) == 0) {
|
||||||
vfs_obj = (*vfsp)->obj;
|
return (*vfsp)->obj;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vfs_obj == NULL) {
|
|
||||||
mp_raise_OSError(MP_EINVAL);
|
mp_raise_OSError(MP_EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
common_hal_storage_umount_object(vfs_obj);
|
void common_hal_storage_umount_path(const char* mount_path) {
|
||||||
|
common_hal_storage_umount_object(storage_object_from_path(mount_path));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user