diff options
author | Nikolay Minaylov <nm29719@gmail.com> | 2022-05-27 14:19:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 14:19:21 +0300 |
commit | 79920a3522092f0a7ad0bb043ba096119ef8057d (patch) | |
tree | 53c81212ed9fee926fc8c7a8f95bf1d762797eee /lib | |
parent | 533f12af15ba6f04fa246d3408d5f55f69179c27 (diff) |
[FL-2491] File browser GUI module (#1237)
* File browser module and test app
* nfc: Add support for saved files in subdirectories
* nfc: Use helper function to get shadow path when loading data
* File browser dialog integration pt.1
* File browser dialog integration pt.2
* Gui,Dialogs: drop file select
* Correct use of dynamic string_t(string_ptr)
Co-authored-by: Yukai Li <yukaili.geek@gmail.com>
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/one_wire/ibutton/ibutton_key.c | 9 | ||||
-rw-r--r-- | lib/one_wire/ibutton/ibutton_key.h | 14 | ||||
-rw-r--r-- | lib/toolbox/path.c | 14 | ||||
-rw-r--r-- | lib/toolbox/path.h | 9 |
4 files changed, 23 insertions, 23 deletions
diff --git a/lib/one_wire/ibutton/ibutton_key.c b/lib/one_wire/ibutton/ibutton_key.c index c6d4466f..2c0f7fa2 100644 --- a/lib/one_wire/ibutton/ibutton_key.c +++ b/lib/one_wire/ibutton/ibutton_key.c @@ -4,7 +4,6 @@ struct iButtonKey { uint8_t data[IBUTTON_KEY_DATA_SIZE]; - char name[IBUTTON_KEY_NAME_SIZE]; iButtonKeyType type; }; @@ -42,14 +41,6 @@ uint8_t ibutton_key_get_data_size(iButtonKey* key) { return ibutton_key_get_size_by_type(key->type); } -void ibutton_key_set_name(iButtonKey* key, const char* name) { - strlcpy(key->name, name, IBUTTON_KEY_NAME_SIZE); -} - -const char* ibutton_key_get_name_p(iButtonKey* key) { - return key->name; -} - void ibutton_key_set_type(iButtonKey* key, iButtonKeyType key_type) { key->type = key_type; } diff --git a/lib/one_wire/ibutton/ibutton_key.h b/lib/one_wire/ibutton/ibutton_key.h index 8d6732bc..f66537d7 100644 --- a/lib/one_wire/ibutton/ibutton_key.h +++ b/lib/one_wire/ibutton/ibutton_key.h @@ -69,20 +69,6 @@ const uint8_t* ibutton_key_get_data_p(iButtonKey* key); uint8_t ibutton_key_get_data_size(iButtonKey* key); /** - * Set key name - * @param key - * @param name - */ -void ibutton_key_set_name(iButtonKey* key, const char* name); - -/** - * Get pointer to key name - * @param key - * @return const char* - */ -const char* ibutton_key_get_name_p(iButtonKey* key); - -/** * Set key type * @param key * @param key_type diff --git a/lib/toolbox/path.c b/lib/toolbox/path.c index 4fd042e4..a99e57d1 100644 --- a/lib/toolbox/path.c +++ b/lib/toolbox/path.c @@ -19,6 +19,20 @@ void path_extract_filename_no_ext(const char* path, string_t filename) { string_mid(filename, start_position, end_position - start_position); } +void path_extract_filename(string_t path, string_t name, bool trim_ext) { + size_t filename_start = string_search_rchar(path, '/'); + if(filename_start > 0) { + filename_start++; + string_set_n(name, path, filename_start, string_size(path) - filename_start); + } + if(trim_ext) { + size_t dot = string_search_rchar(name, '.'); + if(dot > 0) { + string_left(name, dot); + } + } +} + static inline void path_cleanup(string_t path) { string_strim(path); while(string_end_with_str_p(path, "/")) { diff --git a/lib/toolbox/path.h b/lib/toolbox/path.h index 0de63bb2..76e501cc 100644 --- a/lib/toolbox/path.h +++ b/lib/toolbox/path.h @@ -15,6 +15,15 @@ extern "C" { void path_extract_filename_no_ext(const char* path, string_t filename); /** + * @brief Extract filename string from path. + * + * @param path path string + * @param filename output filename string. Must be initialized before. + * @param trim_ext true - get filename without extension + */ +void path_extract_filename(string_t path, string_t filename, bool trim_ext); + +/** * @brief Extract last path component * * @param path path string |