mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 05:06:30 +04:00
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:
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <m-string.h>
|
||||
#include <loader/loader.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <lib/toolbox/crc32_calc.h>
|
||||
@@ -34,9 +33,9 @@ const char* update_operation_describe_preparation_result(const UpdatePrepareResu
|
||||
}
|
||||
}
|
||||
|
||||
static bool update_operation_get_current_package_path_rtc(Storage* storage, string_t out_path) {
|
||||
static bool update_operation_get_current_package_path_rtc(Storage* storage, FuriString* out_path) {
|
||||
const uint32_t update_index = furi_hal_rtc_get_register(FuriHalRtcRegisterUpdateFolderFSIndex);
|
||||
string_set_str(out_path, UPDATE_ROOT_DIR);
|
||||
furi_string_set(out_path, UPDATE_ROOT_DIR);
|
||||
if(update_index == UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC) {
|
||||
return true;
|
||||
}
|
||||
@@ -63,7 +62,7 @@ static bool update_operation_get_current_package_path_rtc(Storage* storage, stri
|
||||
free(name_buffer);
|
||||
storage_file_free(dir);
|
||||
if(!found) {
|
||||
string_reset(out_path);
|
||||
furi_string_reset(out_path);
|
||||
}
|
||||
|
||||
return found;
|
||||
@@ -72,8 +71,8 @@ static bool update_operation_get_current_package_path_rtc(Storage* storage, stri
|
||||
#define UPDATE_FILE_POINTER_FN EXT_PATH(UPDATE_MANIFEST_POINTER_FILE_NAME)
|
||||
#define UPDATE_MANIFEST_MAX_PATH_LEN 256u
|
||||
|
||||
bool update_operation_get_current_package_manifest_path(Storage* storage, string_t out_path) {
|
||||
string_reset(out_path);
|
||||
bool update_operation_get_current_package_manifest_path(Storage* storage, FuriString* out_path) {
|
||||
furi_string_reset(out_path);
|
||||
if(storage_common_stat(storage, UPDATE_FILE_POINTER_FN, NULL) == FSE_OK) {
|
||||
char* manifest_name_buffer = malloc(UPDATE_MANIFEST_MAX_PATH_LEN);
|
||||
File* upd_file = NULL;
|
||||
@@ -91,23 +90,23 @@ bool update_operation_get_current_package_manifest_path(Storage* storage, string
|
||||
if(storage_common_stat(storage, manifest_name_buffer, NULL) != FSE_OK) {
|
||||
break;
|
||||
}
|
||||
string_set_str(out_path, manifest_name_buffer);
|
||||
furi_string_set(out_path, manifest_name_buffer);
|
||||
} while(0);
|
||||
free(manifest_name_buffer);
|
||||
storage_file_free(upd_file);
|
||||
} else {
|
||||
/* legacy, will be deprecated */
|
||||
string_t rtcpath;
|
||||
string_init(rtcpath);
|
||||
FuriString* rtcpath;
|
||||
rtcpath = furi_string_alloc();
|
||||
do {
|
||||
if(!update_operation_get_current_package_path_rtc(storage, rtcpath)) {
|
||||
break;
|
||||
}
|
||||
path_concat(string_get_cstr(rtcpath), UPDATE_MANIFEST_DEFAULT_NAME, out_path);
|
||||
path_concat(furi_string_get_cstr(rtcpath), UPDATE_MANIFEST_DEFAULT_NAME, out_path);
|
||||
} while(0);
|
||||
string_clear(rtcpath);
|
||||
furi_string_free(rtcpath);
|
||||
}
|
||||
return !string_empty_p(out_path);
|
||||
return !furi_string_empty(out_path);
|
||||
}
|
||||
|
||||
static bool update_operation_persist_manifest_path(Storage* storage, const char* manifest_path) {
|
||||
@@ -141,8 +140,8 @@ UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) {
|
||||
File* file = storage_file_alloc(storage);
|
||||
|
||||
uint64_t free_int_space;
|
||||
string_t stage_path;
|
||||
string_init(stage_path);
|
||||
FuriString* stage_path;
|
||||
stage_path = furi_string_alloc();
|
||||
do {
|
||||
if((storage_common_fs_info(storage, STORAGE_INT_PATH_PREFIX, NULL, &free_int_space) !=
|
||||
FSE_OK) ||
|
||||
@@ -171,9 +170,10 @@ UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) {
|
||||
}
|
||||
|
||||
path_extract_dirname(manifest_file_path, stage_path);
|
||||
path_append(stage_path, string_get_cstr(manifest->staged_loader_file));
|
||||
path_append(stage_path, furi_string_get_cstr(manifest->staged_loader_file));
|
||||
|
||||
if(!storage_file_open(file, string_get_cstr(stage_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
if(!storage_file_open(
|
||||
file, furi_string_get_cstr(stage_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
result = UpdatePrepareResultStageMissing;
|
||||
break;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) {
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePreUpdate);
|
||||
} while(false);
|
||||
|
||||
string_clear(stage_path);
|
||||
furi_string_free(stage_path);
|
||||
storage_file_free(file);
|
||||
|
||||
update_manifest_free(manifest);
|
||||
|
||||
Reference in New Issue
Block a user