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:
@@ -5,7 +5,6 @@
|
||||
#include <core/common_defines.h>
|
||||
#include <core/log.h>
|
||||
#include "gui/modules/file_browser_worker.h"
|
||||
#include "m-string.h"
|
||||
#include <math.h>
|
||||
|
||||
static void
|
||||
@@ -19,7 +18,7 @@ static void
|
||||
|
||||
if((item_cnt == 0) && (archive_is_home(browser)) && (tab != ArchiveTabBrowser)) {
|
||||
archive_switch_tab(browser, browser->last_tab_switch_dir);
|
||||
} else if(!string_start_with_str_p(browser->path, "/app:")) {
|
||||
} else if(!furi_string_start_with_str(browser->path, "/app:")) {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
files_array_reset(model->files);
|
||||
@@ -51,12 +50,13 @@ static void archive_list_load_cb(void* context, uint32_t list_load_offset) {
|
||||
});
|
||||
}
|
||||
|
||||
static void archive_list_item_cb(void* context, string_t item_path, bool is_folder, bool is_last) {
|
||||
static void
|
||||
archive_list_item_cb(void* context, FuriString* item_path, bool is_folder, bool is_last) {
|
||||
furi_assert(context);
|
||||
ArchiveBrowserView* browser = (ArchiveBrowserView*)context;
|
||||
|
||||
if(!is_last) {
|
||||
archive_add_file_item(browser, is_folder, string_get_cstr(item_path));
|
||||
archive_add_file_item(browser, is_folder, furi_string_get_cstr(item_path));
|
||||
} else {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
@@ -79,7 +79,7 @@ static void archive_long_load_cb(void* context) {
|
||||
|
||||
static void archive_file_browser_set_path(
|
||||
ArchiveBrowserView* browser,
|
||||
string_t path,
|
||||
FuriString* path,
|
||||
const char* filter_ext,
|
||||
bool skip_assets) {
|
||||
furi_assert(browser);
|
||||
@@ -133,7 +133,7 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target) {
|
||||
furi_assert(browser);
|
||||
furi_assert(target);
|
||||
|
||||
archive_get_items(browser, string_get_cstr(browser->path));
|
||||
archive_get_items(browser, furi_string_get_cstr(browser->path));
|
||||
|
||||
if(!archive_file_get_array_size(browser) && archive_is_home(browser)) {
|
||||
archive_switch_tab(browser, TAB_RIGHT);
|
||||
@@ -143,7 +143,7 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target) {
|
||||
uint16_t idx = 0;
|
||||
while(idx < files_array_size(model->files)) {
|
||||
ArchiveFile_t* current = files_array_get(model->files, idx);
|
||||
if(!string_search(current->path, target)) {
|
||||
if(!furi_string_search(current->path, target)) {
|
||||
model->item_idx = idx + model->array_offset;
|
||||
break;
|
||||
}
|
||||
@@ -315,12 +315,12 @@ bool archive_is_home(ArchiveBrowserView* browser) {
|
||||
}
|
||||
|
||||
const char* default_path = archive_get_default_path(archive_get_tab(browser));
|
||||
return (string_cmp_str(browser->path, default_path) == 0);
|
||||
return (furi_string_cmp_str(browser->path, default_path) == 0);
|
||||
}
|
||||
|
||||
const char* archive_get_name(ArchiveBrowserView* browser) {
|
||||
ArchiveFile_t* selected = archive_get_current_file(browser);
|
||||
return string_get_cstr(selected->path);
|
||||
return furi_string_get_cstr(selected->path);
|
||||
}
|
||||
|
||||
void archive_set_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
|
||||
@@ -339,7 +339,7 @@ void archive_add_app_item(ArchiveBrowserView* browser, const char* name) {
|
||||
|
||||
ArchiveFile_t item;
|
||||
ArchiveFile_t_init(&item);
|
||||
string_set_str(item.path, name);
|
||||
furi_string_set(item.path, name);
|
||||
archive_set_file_type(&item, name, false, true);
|
||||
|
||||
with_view_model(
|
||||
@@ -358,8 +358,8 @@ void archive_add_file_item(ArchiveBrowserView* browser, bool is_folder, const ch
|
||||
ArchiveFile_t item;
|
||||
|
||||
ArchiveFile_t_init(&item);
|
||||
string_init_set_str(item.path, name);
|
||||
archive_set_file_type(&item, string_get_cstr(browser->path), is_folder, false);
|
||||
item.path = furi_string_alloc_set(name);
|
||||
archive_set_file_type(&item, furi_string_get_cstr(browser->path), is_folder, false);
|
||||
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
@@ -379,7 +379,8 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show) {
|
||||
model->menu_idx = 0;
|
||||
ArchiveFile_t* selected =
|
||||
files_array_get(model->files, model->item_idx - model->array_offset);
|
||||
selected->fav = archive_is_favorite("%s", string_get_cstr(selected->path));
|
||||
selected->fav =
|
||||
archive_is_favorite("%s", furi_string_get_cstr(selected->path));
|
||||
}
|
||||
} else {
|
||||
model->menu = false;
|
||||
@@ -400,14 +401,14 @@ void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active) {
|
||||
});
|
||||
}
|
||||
|
||||
static bool archive_is_dir_exists(string_t path) {
|
||||
if(string_equal_str_p(path, STORAGE_ANY_PATH_PREFIX)) {
|
||||
static bool archive_is_dir_exists(FuriString* path) {
|
||||
if(furi_string_equal(path, STORAGE_ANY_PATH_PREFIX)) {
|
||||
return true;
|
||||
}
|
||||
bool state = false;
|
||||
FileInfo file_info;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
if(storage_common_stat(storage, string_get_cstr(path), &file_info) == FSE_OK) {
|
||||
if(storage_common_stat(storage, furi_string_get_cstr(path), &file_info) == FSE_OK) {
|
||||
if(file_info.flags & FSF_DIRECTORY) {
|
||||
state = true;
|
||||
}
|
||||
@@ -431,16 +432,16 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
|
||||
browser->is_root = true;
|
||||
archive_set_tab(browser, tab);
|
||||
|
||||
string_set_str(browser->path, archive_get_default_path(tab));
|
||||
furi_string_set(browser->path, archive_get_default_path(tab));
|
||||
bool tab_empty = true;
|
||||
if(tab == ArchiveTabFavorites) {
|
||||
if(archive_favorites_count(browser) > 0) {
|
||||
tab_empty = false;
|
||||
}
|
||||
} else if(string_start_with_str_p(browser->path, "/app:")) {
|
||||
char* app_name = strchr(string_get_cstr(browser->path), ':');
|
||||
} else if(furi_string_start_with_str(browser->path, "/app:")) {
|
||||
char* app_name = strchr(furi_string_get_cstr(browser->path), ':');
|
||||
if(app_name != NULL) {
|
||||
if(archive_app_is_available(browser, string_get_cstr(browser->path))) {
|
||||
if(archive_app_is_available(browser, furi_string_get_cstr(browser->path))) {
|
||||
tab_empty = false;
|
||||
}
|
||||
}
|
||||
@@ -463,12 +464,12 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
|
||||
model->array_offset = 0;
|
||||
return false;
|
||||
});
|
||||
archive_get_items(browser, string_get_cstr(browser->path));
|
||||
archive_get_items(browser, furi_string_get_cstr(browser->path));
|
||||
archive_update_offset(browser);
|
||||
}
|
||||
}
|
||||
|
||||
void archive_enter_dir(ArchiveBrowserView* browser, string_t path) {
|
||||
void archive_enter_dir(ArchiveBrowserView* browser, FuriString* path) {
|
||||
furi_assert(browser);
|
||||
furi_assert(path);
|
||||
|
||||
@@ -480,7 +481,7 @@ void archive_enter_dir(ArchiveBrowserView* browser, string_t path) {
|
||||
return false;
|
||||
});
|
||||
|
||||
string_set(browser->path, path);
|
||||
furi_string_set(browser->path, path);
|
||||
file_browser_worker_folder_enter(browser->worker, path, idx_temp);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user