From 92f54c45ff4935241403e499600ed5574bfee862 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Fri, 26 May 2023 22:21:32 +0100 Subject: [PATCH] Use rename or move where appropriate --- .../main/archive/helpers/archive_favorites.c | 16 ++++------------ .../main/archive/helpers/archive_files.c | 2 +- .../main/archive/helpers/archive_files.h | 2 +- .../main/archive/scenes/archive_scene_browser.c | 2 +- .../main/archive/scenes/archive_scene_rename.c | 2 +- furi/flipper.c | 3 +-- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/applications/main/archive/helpers/archive_favorites.c b/applications/main/archive/helpers/archive_favorites.c index 9f3039041..c7b058235 100644 --- a/applications/main/archive/helpers/archive_favorites.c +++ b/applications/main/archive/helpers/archive_favorites.c @@ -112,9 +112,7 @@ static bool archive_favourites_rescan() { furi_string_free(buffer); storage_file_close(file); - storage_common_remove(storage, ARCHIVE_FAV_PATH); - storage_common_rename(storage, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); - storage_common_remove(storage, ARCHIVE_FAV_TEMP_PATH); + storage_common_move(storage, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); storage_file_free(file); furi_record_close(RECORD_STORAGE); @@ -217,9 +215,7 @@ bool archive_favorites_delete(const char* format, ...) { furi_string_free(filename); storage_file_close(file); - storage_common_remove(fs_api, ARCHIVE_FAV_PATH); - storage_common_rename(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); - storage_common_remove(fs_api, ARCHIVE_FAV_TEMP_PATH); + storage_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); storage_file_free(file); furi_record_close(RECORD_STORAGE); @@ -302,9 +298,7 @@ bool archive_favorites_rename(const char* src, const char* dst) { furi_string_free(path); storage_file_close(file); - storage_common_remove(fs_api, ARCHIVE_FAV_PATH); - storage_common_rename(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); - storage_common_remove(fs_api, ARCHIVE_FAV_TEMP_PATH); + storage_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); storage_file_free(file); furi_record_close(RECORD_STORAGE); @@ -330,9 +324,7 @@ void archive_favorites_save(void* context) { archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(item->path)); } - storage_common_remove(fs_api, ARCHIVE_FAV_PATH); - storage_common_rename(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); - storage_common_remove(fs_api, ARCHIVE_FAV_TEMP_PATH); + storage_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH); storage_file_free(file); furi_record_close(RECORD_STORAGE); diff --git a/applications/main/archive/helpers/archive_files.c b/applications/main/archive/helpers/archive_files.c index 89abf7355..11a30d956 100644 --- a/applications/main/archive/helpers/archive_files.c +++ b/applications/main/archive/helpers/archive_files.c @@ -115,7 +115,7 @@ void archive_delete_file(void* context, const char* format, ...) { furi_string_free(filename); } -FS_Error archive_copy_move_file_or_dir( +FS_Error archive_copy_rename_file_or_dir( void* context, const char* src_path, const char* dst_path, diff --git a/applications/main/archive/helpers/archive_files.h b/applications/main/archive/helpers/archive_files.h index 984823382..d54b99994 100644 --- a/applications/main/archive/helpers/archive_files.h +++ b/applications/main/archive/helpers/archive_files.h @@ -117,7 +117,7 @@ void archive_file_append(const char* path, const char* format, ...) _ATTRIBUTE((__format__(__printf__, 2, 3))); void archive_delete_file(void* context, const char* format, ...) _ATTRIBUTE((__format__(__printf__, 2, 3))); -FS_Error archive_copy_move_file_or_dir( +FS_Error archive_copy_rename_file_or_dir( void* context, const char* src_path, const char* dst_path, diff --git a/applications/main/archive/scenes/archive_scene_browser.c b/applications/main/archive/scenes/archive_scene_browser.c index 4170c1fd8..bf9079be4 100644 --- a/applications/main/archive/scenes/archive_scene_browser.c +++ b/applications/main/archive/scenes/archive_scene_browser.c @@ -220,7 +220,7 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) { if(path_src && path_dst) { view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewStack); archive_show_loading_popup(archive, true); - FS_Error error = archive_copy_move_file_or_dir( + FS_Error error = archive_copy_rename_file_or_dir( archive->browser, furi_string_get_cstr(path_src), furi_string_get_cstr(path_dst), diff --git a/applications/main/archive/scenes/archive_scene_rename.c b/applications/main/archive/scenes/archive_scene_rename.c index f06339263..cc4ae5e42 100644 --- a/applications/main/archive/scenes/archive_scene_rename.c +++ b/applications/main/archive/scenes/archive_scene_rename.c @@ -85,7 +85,7 @@ bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) { // Long time process if this is directory view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewStack); archive_show_loading_popup(archive, true); - FS_Error error = archive_copy_move_file_or_dir( + FS_Error error = archive_copy_rename_file_or_dir( archive->browser, path_src, furi_string_get_cstr(path_dst), false, false); archive_show_loading_popup(archive, false); diff --git a/furi/flipper.c b/furi/flipper.c index 1b4f4cb62..49d99b03a 100644 --- a/furi/flipper.c +++ b/furi/flipper.c @@ -66,8 +66,7 @@ void flipper_migrate_files() { FileInfo file_info; if(storage_common_stat(storage, U2F_CNT_OLD_FILE, &file_info) == FSE_OK && file_info.size > 200) { // Is on Int and has content - storage_common_remove(storage, U2F_CNT_FILE); // Remove outdated on Ext - storage_common_rename(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE); // Int -> Ext + storage_common_move(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE); // Int -> Ext } storage_common_copy(storage, U2F_KEY_OLD_FILE, U2F_KEY_FILE); // Ext -> Int