diff --git a/applications/archive/archive.c b/applications/archive/archive.c index 80b0d273..40ba6d9d 100644 --- a/applications/archive/archive.c +++ b/applications/archive/archive.c @@ -8,12 +8,12 @@ static bool is_favourite(ArchiveApp* archive, ArchiveFile_t* file) { FS_Error fr; string_t path; - string_init_set(path, "favourites/"); - string_cat(path, file->name); + string_init_printf(path, "favourites/%s", string_get_cstr(file->name)); fr = common_api->info(string_get_cstr(path), &file_info, NULL, 0); FURI_LOG_I("FAV", "%d", fr); + string_clear(path); return fr == 0 || fr == 2; } @@ -241,12 +241,12 @@ static void archive_add_to_favourites(ArchiveApp* archive) { string_t buffer_src; string_t buffer_dst; - string_init_set(buffer_src, archive->browser.path); - string_cat(buffer_src, "/"); - string_cat(buffer_src, archive->browser.name); - - string_init_set_str(buffer_dst, "/favourites/"); - string_cat(buffer_dst, archive->browser.name); + string_init_printf( + buffer_src, + "%s/%s", + string_get_cstr(archive->browser.path), + string_get_cstr(archive->browser.name)); + string_init_printf(buffer_dst, "/favourites/%s", string_get_cstr(archive->browser.name)); fr = file_api->open(&src, string_get_cstr(buffer_src), FSAM_READ, FSOM_OPEN_EXISTING); FURI_LOG_I("FATFS", "OPEN: %d", fr); @@ -276,14 +276,16 @@ static void archive_text_input_callback(void* context) { string_t buffer_src; string_t buffer_dst; - string_init_set(buffer_src, archive->browser.path); - string_init_set(buffer_dst, archive->browser.path); - - string_cat(buffer_src, "/"); - string_cat(buffer_dst, "/"); - - string_cat(buffer_src, archive->browser.name); - string_cat_str(buffer_dst, archive->browser.text_input_buffer); + string_init_printf( + buffer_src, + "%s/%s", + string_get_cstr(archive->browser.path), + string_get_cstr(archive->browser.name)); + string_init_printf( + buffer_dst, + "%s/%s", + string_get_cstr(archive->browser.path), + archive->browser.text_input_buffer); // append extension @@ -312,9 +314,7 @@ static void archive_enter_text_input(ArchiveApp* archive) { *archive->browser.text_input_buffer = '\0'; strlcpy( - archive->browser.text_input_buffer, - string_get_cstr(archive->browser.name), - string_size(archive->browser.name)); + archive->browser.text_input_buffer, string_get_cstr(archive->browser.name), MAX_NAME_LEN); archive_trim_file_ext(archive->browser.text_input_buffer); @@ -376,20 +376,17 @@ static void archive_delete_file(ArchiveApp* archive, ArchiveFile_t* file, bool f string_init(path); if(!fav && !orig) { - string_set(path, archive->browser.path); - string_cat(path, "/"); - string_cat(path, file->name); + string_printf( + path, "%s/%s", string_get_cstr(archive->browser.path), string_get_cstr(file->name)); common_api->remove(string_get_cstr(path)); } else { // remove from favorites - string_set(path, "favourites/"); - string_cat(path, file->name); + string_printf(path, "favourites/%s", string_get_cstr(file->name)); common_api->remove(string_get_cstr(path)); if(orig) { // remove original file - string_set_str(path, get_default_path(file->type)); - string_cat(path, "/"); - string_cat(path, file->name); + string_printf( + path, "%s/%s", get_default_path(file->type), string_get_cstr(file->name)); common_api->remove(string_get_cstr(path)); } } @@ -423,9 +420,11 @@ static void archive_file_menu_callback(ArchiveApp* archive) { case 0: if(is_known_app(selected->type)) { string_t full_path; - string_init_set(full_path, archive->browser.path); - string_cat(full_path, "/"); - string_cat(full_path, selected->name); + string_init_printf( + full_path, + "%s/%s", + string_get_cstr(archive->browser.path), + string_get_cstr(selected->name)); archive_open_app( archive, flipper_app_name[selected->type], string_get_cstr(full_path)); diff --git a/applications/ibutton/helpers/pulse-sequencer.cpp b/applications/ibutton/helpers/pulse-sequencer.cpp index efe00d7b..c7637b4d 100644 --- a/applications/ibutton/helpers/pulse-sequencer.cpp +++ b/applications/ibutton/helpers/pulse-sequencer.cpp @@ -16,11 +16,11 @@ void PulseSequencer::start() { callback_pointer = cbc::obtain_connector(this, &PulseSequencer::timer_elapsed_callback); api_interrupt_add(callback_pointer, InterruptTypeTimerUpdate, this); + period_index = 1; init_timer(periods[period_index]); pin_state = pin_start_state; hal_gpio_write(&ibutton_gpio, pin_state); pin_state = !pin_state; - period_index = 1; HAL_TIM_Base_Start_IT(&htim1); }