M*LIB: non-inlined strings, FuriString primitive (#1795)
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -36,9 +36,9 @@ static LfRfid* lfrfid_alloc() {
|
||||
lfrfid->storage = furi_record_open(RECORD_STORAGE);
|
||||
lfrfid->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
||||
string_init(lfrfid->file_name);
|
||||
string_init(lfrfid->raw_file_name);
|
||||
string_init_set_str(lfrfid->file_path, LFRFID_APP_FOLDER);
|
||||
lfrfid->file_name = furi_string_alloc();
|
||||
lfrfid->raw_file_name = furi_string_alloc();
|
||||
lfrfid->file_path = furi_string_alloc_set(LFRFID_APP_FOLDER);
|
||||
|
||||
lfrfid->dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
|
||||
@@ -104,9 +104,9 @@ static LfRfid* lfrfid_alloc() {
|
||||
static void lfrfid_free(LfRfid* lfrfid) {
|
||||
furi_assert(lfrfid);
|
||||
|
||||
string_clear(lfrfid->raw_file_name);
|
||||
string_clear(lfrfid->file_name);
|
||||
string_clear(lfrfid->file_path);
|
||||
furi_string_free(lfrfid->raw_file_name);
|
||||
furi_string_free(lfrfid->file_name);
|
||||
furi_string_free(lfrfid->file_path);
|
||||
protocol_dict_free(lfrfid->dict);
|
||||
|
||||
lfrfid_worker_free(lfrfid->lfworker);
|
||||
@@ -183,7 +183,7 @@ int32_t lfrfid_app(void* p) {
|
||||
app->view_dispatcher, app->gui, ViewDispatcherTypeDesktop);
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidSceneRpc);
|
||||
} else {
|
||||
string_set_str(app->file_path, args);
|
||||
furi_string_set(app->file_path, args);
|
||||
lfrfid_load_key_data(app, app->file_path, true);
|
||||
view_dispatcher_attach_to_gui(
|
||||
app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
@@ -210,13 +210,13 @@ bool lfrfid_save_key(LfRfid* app) {
|
||||
|
||||
lfrfid_make_app_folder(app);
|
||||
|
||||
if(string_end_with_str_p(app->file_path, LFRFID_APP_EXTENSION)) {
|
||||
size_t filename_start = string_search_rchar(app->file_path, '/');
|
||||
string_left(app->file_path, filename_start);
|
||||
if(furi_string_end_with(app->file_path, LFRFID_APP_EXTENSION)) {
|
||||
size_t filename_start = furi_string_search_rchar(app->file_path, '/');
|
||||
furi_string_left(app->file_path, filename_start);
|
||||
}
|
||||
|
||||
string_cat_printf(
|
||||
app->file_path, "/%s%s", string_get_cstr(app->file_name), LFRFID_APP_EXTENSION);
|
||||
furi_string_cat_printf(
|
||||
app->file_path, "/%s%s", furi_string_get_cstr(app->file_name), LFRFID_APP_EXTENSION);
|
||||
|
||||
result = lfrfid_save_key_data(app, app->file_path);
|
||||
return result;
|
||||
@@ -242,14 +242,14 @@ bool lfrfid_load_key_from_file_select(LfRfid* app) {
|
||||
bool lfrfid_delete_key(LfRfid* app) {
|
||||
furi_assert(app);
|
||||
|
||||
return storage_simply_remove(app->storage, string_get_cstr(app->file_path));
|
||||
return storage_simply_remove(app->storage, furi_string_get_cstr(app->file_path));
|
||||
}
|
||||
|
||||
bool lfrfid_load_key_data(LfRfid* app, string_t path, bool show_dialog) {
|
||||
bool lfrfid_load_key_data(LfRfid* app, FuriString* path, bool show_dialog) {
|
||||
bool result = false;
|
||||
|
||||
do {
|
||||
app->protocol_id = lfrfid_dict_file_load(app->dict, string_get_cstr(path));
|
||||
app->protocol_id = lfrfid_dict_file_load(app->dict, furi_string_get_cstr(path));
|
||||
if(app->protocol_id == PROTOCOL_NO) break;
|
||||
|
||||
path_extract_filename(path, app->file_name, true);
|
||||
@@ -263,8 +263,8 @@ bool lfrfid_load_key_data(LfRfid* app, string_t path, bool show_dialog) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool lfrfid_save_key_data(LfRfid* app, string_t path) {
|
||||
bool result = lfrfid_dict_file_save(app->dict, app->protocol_id, string_get_cstr(path));
|
||||
bool lfrfid_save_key_data(LfRfid* app, FuriString* path) {
|
||||
bool result = lfrfid_dict_file_save(app->dict, app->protocol_id, furi_string_get_cstr(path));
|
||||
|
||||
if(!result) {
|
||||
dialog_message_show_storage_error(app->dialogs, "Cannot save\nkey file");
|
||||
|
||||
Reference in New Issue
Block a user