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:
Sergey Gavrilov
2022-10-06 01:15:23 +10:00
committed by GitHub
parent 0f9ea925d3
commit 4bf29827f8
370 changed files with 5597 additions and 3963 deletions

View File

@@ -22,19 +22,22 @@
static bool update_task_pre_update(UpdateTask* update_task) {
bool success = false;
string_t backup_file_path;
string_init(backup_file_path);
FuriString* backup_file_path;
backup_file_path = furi_string_alloc();
path_concat(
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, backup_file_path);
furi_string_get_cstr(update_task->update_path),
LFS_BACKUP_DEFAULT_FILENAME,
backup_file_path);
update_task_set_progress(update_task, UpdateTaskStageLfsBackup, 0);
/* to avoid bootloops */
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
if((success = lfs_backup_create(update_task->storage, string_get_cstr(backup_file_path)))) {
if((success =
lfs_backup_create(update_task->storage, furi_string_get_cstr(backup_file_path)))) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeUpdate);
}
string_clear(backup_file_path);
furi_string_free(backup_file_path);
return success;
}
@@ -79,12 +82,12 @@ static void
/* For this stage, first 30% of progress = cleanup */
(n_processed_files++ * 30) / (n_approx_file_entries + 1));
string_t file_path;
string_init(file_path);
path_concat(STORAGE_EXT_PATH_PREFIX, string_get_cstr(entry_ptr->name), file_path);
FURI_LOG_D(TAG, "Removing %s", string_get_cstr(file_path));
storage_simply_remove(update_task->storage, string_get_cstr(file_path));
string_clear(file_path);
FuriString* file_path = furi_string_alloc();
path_concat(
STORAGE_EXT_PATH_PREFIX, furi_string_get_cstr(entry_ptr->name), file_path);
FURI_LOG_D(TAG, "Removing %s", furi_string_get_cstr(file_path));
storage_simply_remove(update_task->storage, furi_string_get_cstr(file_path));
furi_string_free(file_path);
}
}
} while(false);
@@ -94,17 +97,19 @@ static void
static bool update_task_post_update(UpdateTask* update_task) {
bool success = false;
string_t file_path;
string_init(file_path);
FuriString* file_path;
file_path = furi_string_alloc();
TarArchive* archive = tar_archive_alloc(update_task->storage);
do {
path_concat(
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, file_path);
furi_string_get_cstr(update_task->update_path),
LFS_BACKUP_DEFAULT_FILENAME,
file_path);
update_task_set_progress(update_task, UpdateTaskStageLfsRestore, 0);
CHECK_RESULT(lfs_backup_unpack(update_task->storage, string_get_cstr(file_path)));
CHECK_RESULT(lfs_backup_unpack(update_task->storage, furi_string_get_cstr(file_path)));
if(update_task->state.groups & UpdateTaskStageGroupResources) {
TarUnpackProgress progress = {
@@ -115,13 +120,13 @@ static bool update_task_post_update(UpdateTask* update_task) {
update_task_set_progress(update_task, UpdateTaskStageResourcesUpdate, 0);
path_concat(
string_get_cstr(update_task->update_path),
string_get_cstr(update_task->manifest->resource_bundle),
furi_string_get_cstr(update_task->update_path),
furi_string_get_cstr(update_task->manifest->resource_bundle),
file_path);
tar_archive_set_file_callback(archive, update_task_resource_unpack_cb, &progress);
CHECK_RESULT(
tar_archive_open(archive, string_get_cstr(file_path), TAR_OPEN_MODE_READ));
tar_archive_open(archive, furi_string_get_cstr(file_path), TAR_OPEN_MODE_READ));
progress.total_files = tar_archive_get_entries_count(archive);
if(progress.total_files > 0) {
@@ -133,23 +138,23 @@ static bool update_task_post_update(UpdateTask* update_task) {
if(update_task->state.groups & UpdateTaskStageGroupSplashscreen) {
update_task_set_progress(update_task, UpdateTaskStageSplashscreenInstall, 0);
string_t tmp_path;
string_init_set(tmp_path, update_task->update_path);
path_append(tmp_path, string_get_cstr(update_task->manifest->splash_file));
FuriString* tmp_path;
tmp_path = furi_string_alloc_set(update_task->update_path);
path_append(tmp_path, furi_string_get_cstr(update_task->manifest->splash_file));
if(storage_common_copy(
update_task->storage,
string_get_cstr(tmp_path),
furi_string_get_cstr(tmp_path),
INT_PATH(SLIDESHOW_FILE_NAME)) != FSE_OK) {
// actually, not critical
}
string_clear(tmp_path);
furi_string_free(tmp_path);
update_task_set_progress(update_task, UpdateTaskStageSplashscreenInstall, 100);
}
success = true;
} while(false);
tar_archive_free(archive);
string_clear(file_path);
furi_string_free(file_path);
return success;
}