[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>
This commit is contained in:
@@ -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, "/")) {
|
||||
|
@@ -14,6 +14,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
|
||||
*
|
||||
|
Reference in New Issue
Block a user