[FL-1050] SD card error view (#399)

* sd-filesystem: add check error to api
* sd-filesystem: call error check from file select
* ibutton: process sd card error on key saving

Co-authored-by: rusdacent <57439765+rusdacent@users.noreply.github.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-04-07 10:37:10 +03:00
committed by GitHub
parent 5cd73ac97b
commit 8ce5af1be2
4 changed files with 38 additions and 10 deletions

View File

@@ -41,12 +41,16 @@ bool iButtonSceneSaveName::on_event(iButtonApp* app, iButtonEvent* event) {
app->get_fs_api()->common.mkdir("ibutton");
bool res = app->get_fs_api()->file.open(
&key_file, string_get_cstr(key_file_name), FSAM_WRITE, FSOM_CREATE_ALWAYS);
// TODO process file system errors from file system service
if(res) {
res = app->get_fs_api()->file.write(&key_file, key_data, IBUTTON_KEY_SIZE + 1);
res = app->get_fs_api()->file.close(&key_file);
app->switch_to_next_scene(iButtonApp::Scene::SceneSaveSuccess);
} else {
app->get_sd_ex_api()->check_error(app->get_sd_ex_api()->context);
app->switch_to_next_scene(iButtonApp::Scene::SceneStart);
}
string_clear(key_file_name);
app->switch_to_next_scene(iButtonApp::Scene::SceneSaveSuccess);
consumed = true;
}