[FL-2675] /int space reservation (#1448)
* storage: added global #defines for /int, /ext & /any * storage: introduced PATH_EXT, PATH_INT& PATH_ANY macros * core apps: moved hardcoded config files names to separate headers; prefixed them with "."; updater: added file name migration to new naming convention on backup extraction * storage: fixed storage_merge_recursive handling of complex directory structures; storage_move_to_sd: changed data migration logic to all non-dot files & all folders * core: added macro aliases for core record names * Bumped protobuf commit pointer * storage: reserved 5 pages in /int; denying write&creation of non-dot files when running out of free space Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -85,7 +85,7 @@ static bool
|
||||
}
|
||||
|
||||
static void infrared_find_vacant_remote_name(string_t name, const char* path) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
string_t base_path;
|
||||
string_init_set_str(base_path, path);
|
||||
@@ -122,7 +122,7 @@ static void infrared_find_vacant_remote_name(string_t name, const char* path) {
|
||||
}
|
||||
|
||||
string_clear(base_path);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static Infrared* infrared_alloc() {
|
||||
@@ -140,7 +140,7 @@ static Infrared* infrared_alloc() {
|
||||
infrared->scene_manager = scene_manager_alloc(&infrared_scene_handlers, infrared);
|
||||
infrared->view_dispatcher = view_dispatcher_alloc();
|
||||
|
||||
infrared->gui = furi_record_open("gui");
|
||||
infrared->gui = furi_record_open(RECORD_GUI);
|
||||
|
||||
ViewDispatcher* view_dispatcher = infrared->view_dispatcher;
|
||||
view_dispatcher_enable_queue(view_dispatcher);
|
||||
@@ -149,9 +149,9 @@ static Infrared* infrared_alloc() {
|
||||
view_dispatcher_set_navigation_event_callback(view_dispatcher, infrared_back_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(view_dispatcher, infrared_tick_event_callback, 100);
|
||||
|
||||
infrared->storage = furi_record_open("storage");
|
||||
infrared->dialogs = furi_record_open("dialogs");
|
||||
infrared->notifications = furi_record_open("notification");
|
||||
infrared->storage = furi_record_open(RECORD_STORAGE);
|
||||
infrared->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
infrared->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
infrared->worker = infrared_worker_alloc();
|
||||
infrared->remote = infrared_remote_alloc();
|
||||
@@ -242,16 +242,16 @@ static void infrared_free(Infrared* infrared) {
|
||||
infrared_remote_free(infrared->remote);
|
||||
infrared_worker_free(infrared->worker);
|
||||
|
||||
furi_record_close("gui");
|
||||
furi_record_close(RECORD_GUI);
|
||||
infrared->gui = NULL;
|
||||
|
||||
furi_record_close("notification");
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
infrared->notifications = NULL;
|
||||
|
||||
furi_record_close("dialogs");
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
infrared->dialogs = NULL;
|
||||
|
||||
furi_record_close("gui");
|
||||
furi_record_close(RECORD_GUI);
|
||||
infrared->gui = NULL;
|
||||
|
||||
string_clear(infrared->file_path);
|
||||
@@ -302,7 +302,7 @@ bool infrared_rename_current_remote(Infrared* infrared, const char* name) {
|
||||
}
|
||||
string_cat_printf(new_path, "/%s%s", string_get_cstr(new_name), INFRARED_APP_EXTENSION);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
FS_Error status = storage_common_rename(
|
||||
storage, infrared_remote_get_path(remote), string_get_cstr(new_path));
|
||||
@@ -312,7 +312,7 @@ bool infrared_rename_current_remote(Infrared* infrared, const char* name) {
|
||||
string_clear(new_name);
|
||||
string_clear(new_path);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return (status == FSE_OK || status == FSE_EXIST);
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,7 @@ bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
|
||||
furi_assert(brute_force->db_filename);
|
||||
bool success = false;
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
|
||||
|
||||
success = flipper_format_buffered_file_open_existing(ff, brute_force->db_filename);
|
||||
@@ -68,7 +68,7 @@ bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
|
||||
}
|
||||
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -94,14 +94,14 @@ bool infrared_brute_force_start(
|
||||
}
|
||||
|
||||
if(*record_count) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
brute_force->ff = flipper_format_buffered_file_alloc(storage);
|
||||
success =
|
||||
flipper_format_buffered_file_open_existing(brute_force->ff, brute_force->db_filename);
|
||||
if(!success) {
|
||||
flipper_format_free(brute_force->ff);
|
||||
brute_force->ff = NULL;
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
@@ -117,7 +117,7 @@ void infrared_brute_force_stop(InfraredBruteForce* brute_force) {
|
||||
|
||||
string_reset(brute_force->current_record_name);
|
||||
flipper_format_free(brute_force->ff);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
brute_force->ff = NULL;
|
||||
}
|
||||
|
||||
|
@@ -192,9 +192,9 @@ static void infrared_cli_start_ir(Cli* cli, string_t args, void* context) {
|
||||
}
|
||||
void infrared_on_system_start() {
|
||||
#ifdef SRV_CLI
|
||||
Cli* cli = (Cli*)furi_record_open("cli");
|
||||
Cli* cli = (Cli*)furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, "ir", CliCommandFlagDefault, infrared_cli_start_ir, NULL);
|
||||
furi_record_close("cli");
|
||||
furi_record_close(RECORD_CLI);
|
||||
#else
|
||||
UNUSED(infrared_cli_start_ir);
|
||||
#endif
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#define INFRARED_MAX_BUTTON_NAME_LENGTH 22
|
||||
#define INFRARED_MAX_REMOTE_NAME_LENGTH 22
|
||||
|
||||
#define INFRARED_APP_FOLDER "/any/infrared"
|
||||
#define INFRARED_APP_FOLDER ANY_PATH("infrared")
|
||||
#define INFRARED_APP_EXTENSION ".ir"
|
||||
|
||||
#define INFRARED_DEFAULT_REMOTE_NAME "Remote"
|
||||
|
@@ -110,7 +110,7 @@ bool infrared_remote_delete_button(InfraredRemote* remote, size_t index) {
|
||||
}
|
||||
|
||||
bool infrared_remote_store(InfraredRemote* remote) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
||||
const char* path = string_get_cstr(remote->path);
|
||||
|
||||
@@ -134,12 +134,12 @@ bool infrared_remote_store(InfraredRemote* remote) {
|
||||
}
|
||||
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool infrared_remote_load(InfraredRemote* remote, string_t path) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
|
||||
|
||||
string_t buf;
|
||||
@@ -174,16 +174,16 @@ bool infrared_remote_load(InfraredRemote* remote, string_t path) {
|
||||
|
||||
string_clear(buf);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool infrared_remote_remove(InfraredRemote* remote) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
FS_Error status = storage_common_remove(storage, string_get_cstr(remote->path));
|
||||
infrared_remote_reset(remote);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return (status == FSE_OK || status == FSE_NOT_EXIST);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ void infrared_scene_universal_tv_on_enter(void* context) {
|
||||
ButtonPanel* button_panel = infrared->button_panel;
|
||||
InfraredBruteForce* brute_force = infrared->brute_force;
|
||||
|
||||
infrared_brute_force_set_db_filename(brute_force, "/ext/infrared/assets/tv.ir");
|
||||
infrared_brute_force_set_db_filename(brute_force, EXT_PATH("infrared/assets/tv.ir"));
|
||||
|
||||
button_panel_reserve(button_panel, 2, 3);
|
||||
uint32_t i = 0;
|
||||
|
Reference in New Issue
Block a user