2021-05-18 18:54:56 +00:00
|
|
|
#include "archive_i.h"
|
|
|
|
|
|
|
|
static bool archive_get_filenames(ArchiveApp* archive);
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
static bool is_favorite(ArchiveApp* archive, ArchiveFile_t* file) {
|
2021-06-25 16:57:42 +00:00
|
|
|
FileInfo file_info;
|
|
|
|
FS_Error fr;
|
|
|
|
string_t path;
|
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
string_init_printf(path, "%s/%s", get_favorites_path(), string_get_cstr(file->name));
|
2021-06-25 16:57:42 +00:00
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
fr = storage_common_stat(archive->api, string_get_cstr(path), &file_info);
|
2021-06-25 16:57:42 +00:00
|
|
|
FURI_LOG_I("FAV", "%d", fr);
|
|
|
|
|
2021-07-05 12:34:58 +00:00
|
|
|
string_clear(path);
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
return (fr == FSE_OK || fr == FSE_EXIST);
|
2021-06-25 16:57:42 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
static void update_offset(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
size_t array_size = files_array_size(model->files);
|
|
|
|
uint16_t bounds = array_size > 3 ? 2 : array_size;
|
2021-06-25 16:57:42 +00:00
|
|
|
|
|
|
|
if(array_size > 3 && model->idx >= array_size - 1) {
|
|
|
|
model->list_offset = model->idx - 3;
|
|
|
|
} else if(model->list_offset < model->idx - bounds) {
|
|
|
|
model->list_offset = CLAMP(model->list_offset + 1, array_size - bounds, 0);
|
2021-06-23 21:46:52 +00:00
|
|
|
} else if(model->list_offset > model->idx - bounds) {
|
2021-06-25 16:57:42 +00:00
|
|
|
model->list_offset = CLAMP(model->idx - 1, array_size - bounds, 0);
|
2021-06-23 21:46:52 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_update_last_idx(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
archive->browser.last_idx[archive->browser.depth] =
|
|
|
|
CLAMP(model->idx, files_array_size(model->files) - 1, 0);
|
|
|
|
model->idx = 0;
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_switch_dir(ArchiveApp* archive, const char* path) {
|
|
|
|
furi_assert(archive);
|
|
|
|
furi_assert(path);
|
|
|
|
string_set(archive->browser.path, path);
|
|
|
|
archive_get_filenames(archive);
|
2021-06-25 16:57:42 +00:00
|
|
|
update_offset(archive);
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_switch_tab(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
model->tab_idx = archive->browser.tab_id;
|
|
|
|
model->idx = 0;
|
2021-06-25 16:57:42 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
archive->browser.depth = 0;
|
|
|
|
archive_switch_dir(archive, tab_default_paths[archive->browser.tab_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_leave_dir(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
2021-06-25 16:57:42 +00:00
|
|
|
char* last_char_ptr = strrchr(string_get_cstr(archive->browser.path), '/');
|
|
|
|
|
|
|
|
if(last_char_ptr) {
|
|
|
|
size_t pos = last_char_ptr - string_get_cstr(archive->browser.path);
|
|
|
|
string_left(archive->browser.path, pos);
|
2021-06-23 21:46:52 +00:00
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
archive->browser.depth = CLAMP(archive->browser.depth - 1, MAX_DEPTH, 0);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
model->idx = archive->browser.last_idx[archive->browser.depth];
|
2021-06-25 16:57:42 +00:00
|
|
|
model->list_offset =
|
|
|
|
model->idx -
|
|
|
|
(files_array_size(model->files) > 3 ? 3 : files_array_size(model->files));
|
2021-06-23 21:46:52 +00:00
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
archive_switch_dir(archive, string_get_cstr(archive->browser.path));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_enter_dir(ArchiveApp* archive, string_t name) {
|
|
|
|
furi_assert(archive);
|
|
|
|
furi_assert(name);
|
|
|
|
|
|
|
|
archive_update_last_idx(archive);
|
|
|
|
archive->browser.depth = CLAMP(archive->browser.depth + 1, MAX_DEPTH, 0);
|
|
|
|
|
|
|
|
string_cat(archive->browser.path, "/");
|
|
|
|
string_cat(archive->browser.path, archive->browser.name);
|
|
|
|
|
|
|
|
archive_switch_dir(archive, string_get_cstr(archive->browser.path));
|
|
|
|
}
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
static bool filter_by_extension(ArchiveApp* archive, FileInfo* file_info, const char* name) {
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_assert(archive);
|
|
|
|
furi_assert(file_info);
|
|
|
|
furi_assert(name);
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
const char* filter_ext_ptr = get_tab_ext(archive->browser.tab_id);
|
|
|
|
|
|
|
|
if(strcmp(filter_ext_ptr, "*") == 0) {
|
|
|
|
result = true;
|
|
|
|
} else if(strstr(name, filter_ext_ptr) != NULL) {
|
|
|
|
result = true;
|
2021-06-25 16:57:42 +00:00
|
|
|
} else if(file_info->flags & FSF_DIRECTORY) {
|
|
|
|
result = true;
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_file_type(ArchiveFile_t* file, FileInfo* file_info) {
|
|
|
|
furi_assert(file);
|
|
|
|
furi_assert(file_info);
|
|
|
|
|
|
|
|
for(size_t i = 0; i < SIZEOF_ARRAY(known_ext); i++) {
|
|
|
|
if(string_search_str(file->name, known_ext[i], 0) != STRING_FAILURE) {
|
|
|
|
file->type = i;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(file_info->flags & FSF_DIRECTORY) {
|
|
|
|
file->type = ArchiveFileTypeFolder;
|
|
|
|
} else {
|
|
|
|
file->type = ArchiveFileTypeUnknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool archive_get_filenames(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
ArchiveFile_t item;
|
|
|
|
FileInfo file_info;
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
File* directory = storage_file_alloc(archive->api);
|
2021-06-23 21:46:52 +00:00
|
|
|
char name[MAX_NAME_LEN];
|
2021-05-18 18:54:56 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
files_array_clean(model->files);
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
if(!storage_dir_open(directory, string_get_cstr(archive->browser.path))) {
|
|
|
|
storage_dir_close(directory);
|
|
|
|
storage_file_free(directory);
|
2021-05-18 18:54:56 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(1) {
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
if(!storage_dir_read(directory, &file_info, name, MAX_NAME_LEN)) {
|
2021-05-18 18:54:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
uint16_t files_cnt;
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
files_cnt = files_array_size(model->files);
|
2021-06-23 21:46:52 +00:00
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
return true;
|
|
|
|
});
|
2021-06-23 21:46:52 +00:00
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
if(files_cnt > MAX_FILES) {
|
|
|
|
break;
|
|
|
|
} else if(storage_file_get_error(directory) == FSE_OK) {
|
|
|
|
if(filter_by_extension(archive, &file_info, name)) {
|
|
|
|
ArchiveFile_t_init(&item);
|
|
|
|
string_init_set(item.name, name);
|
|
|
|
set_file_type(&item, &file_info);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
files_array_push_back(model->files, item);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
ArchiveFile_t_clear(&item);
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
} else {
|
|
|
|
storage_dir_close(directory);
|
|
|
|
storage_file_free(directory);
|
|
|
|
return false;
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
storage_dir_close(directory);
|
|
|
|
storage_file_free(directory);
|
2021-05-18 18:54:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_exit_callback(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
|
|
|
AppEvent event;
|
|
|
|
event.type = EventTypeExit;
|
|
|
|
furi_check(osMessageQueuePut(archive->event_queue, &event, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t archive_previous_callback(void* context) {
|
|
|
|
return ArchiveViewMain;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* file menu */
|
2021-07-18 18:09:00 +00:00
|
|
|
static void archive_add_to_favorites(ArchiveApp* archive) {
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_assert(archive);
|
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
storage_common_mkdir(archive->api, get_favorites_path());
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
string_t buffer_src;
|
|
|
|
string_t buffer_dst;
|
|
|
|
|
2021-07-05 12:34:58 +00:00
|
|
|
string_init_printf(
|
|
|
|
buffer_src,
|
|
|
|
"%s/%s",
|
|
|
|
string_get_cstr(archive->browser.path),
|
|
|
|
string_get_cstr(archive->browser.name));
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
string_init_printf(
|
|
|
|
buffer_dst, "%s/%s", get_favorites_path(), string_get_cstr(archive->browser.name));
|
2021-06-25 16:57:42 +00:00
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
storage_common_copy(archive->api, string_get_cstr(buffer_src), string_get_cstr(buffer_dst));
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
string_clear(buffer_src);
|
|
|
|
string_clear(buffer_dst);
|
|
|
|
}
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
static void archive_text_input_callback(void* context) {
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
ArchiveApp* archive = (ArchiveApp*)context;
|
|
|
|
|
|
|
|
string_t buffer_src;
|
|
|
|
string_t buffer_dst;
|
|
|
|
|
2021-07-05 12:34:58 +00:00
|
|
|
string_init_printf(
|
|
|
|
buffer_src,
|
|
|
|
"%s/%s",
|
|
|
|
string_get_cstr(archive->browser.path),
|
|
|
|
string_get_cstr(archive->browser.name));
|
|
|
|
string_init_printf(
|
|
|
|
buffer_dst,
|
|
|
|
"%s/%s",
|
|
|
|
string_get_cstr(archive->browser.path),
|
|
|
|
archive->browser.text_input_buffer);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
2021-06-07 16:47:27 +00:00
|
|
|
// append extension
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
ArchiveFile_t* file;
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
file = files_array_get(
|
|
|
|
model->files, CLAMP(model->idx, files_array_size(model->files) - 1, 0));
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
string_cat(buffer_dst, known_ext[file->type]);
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
storage_common_rename(archive->api, string_get_cstr(buffer_src), string_get_cstr(buffer_dst));
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewMain);
|
|
|
|
|
|
|
|
string_clear(buffer_src);
|
|
|
|
string_clear(buffer_dst);
|
|
|
|
|
|
|
|
archive_get_filenames(archive);
|
|
|
|
}
|
2021-06-23 21:46:52 +00:00
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
static void archive_enter_text_input(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
2021-06-23 21:46:52 +00:00
|
|
|
*archive->browser.text_input_buffer = '\0';
|
2021-05-18 18:54:56 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
strlcpy(
|
2021-07-05 12:34:58 +00:00
|
|
|
archive->browser.text_input_buffer, string_get_cstr(archive->browser.name), MAX_NAME_LEN);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
2021-06-07 16:47:27 +00:00
|
|
|
archive_trim_file_ext(archive->browser.text_input_buffer);
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
text_input_set_header_text(archive->text_input, "Rename:");
|
|
|
|
|
|
|
|
text_input_set_result_callback(
|
|
|
|
archive->text_input,
|
|
|
|
archive_text_input_callback,
|
|
|
|
archive,
|
2021-06-23 21:46:52 +00:00
|
|
|
archive->browser.text_input_buffer,
|
2021-07-25 11:34:54 +00:00
|
|
|
MAX_NAME_LEN,
|
|
|
|
false);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewTextInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_show_file_menu(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
|
|
|
archive->browser.menu = true;
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
2021-06-25 16:57:42 +00:00
|
|
|
ArchiveFile_t* selected;
|
|
|
|
selected = files_array_get(model->files, model->idx);
|
2021-06-23 21:46:52 +00:00
|
|
|
model->menu = true;
|
|
|
|
model->menu_idx = 0;
|
2021-07-18 18:09:00 +00:00
|
|
|
selected->fav = is_favorite(archive, selected);
|
2021-06-25 16:57:42 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_close_file_menu(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
|
|
|
archive->browser.menu = false;
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
model->menu = false;
|
|
|
|
model->menu_idx = 0;
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 16:23:25 +00:00
|
|
|
static void archive_open_app(ArchiveApp* archive, const char* app_name, const char* args) {
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_assert(archive);
|
2021-05-26 16:23:25 +00:00
|
|
|
furi_assert(app_name);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
loader_start(archive->loader, app_name, args);
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 16:57:42 +00:00
|
|
|
static void archive_delete_file(ArchiveApp* archive, ArchiveFile_t* file, bool fav, bool orig) {
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_assert(archive);
|
2021-06-25 16:57:42 +00:00
|
|
|
furi_assert(file);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
string_t path;
|
2021-06-25 16:57:42 +00:00
|
|
|
string_init(path);
|
|
|
|
|
|
|
|
if(!fav && !orig) {
|
2021-07-05 12:34:58 +00:00
|
|
|
string_printf(
|
|
|
|
path, "%s/%s", string_get_cstr(archive->browser.path), string_get_cstr(file->name));
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
storage_common_remove(archive->api, string_get_cstr(path));
|
2021-06-25 16:57:42 +00:00
|
|
|
|
|
|
|
} else { // remove from favorites
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
string_printf(path, "%s/%s", get_favorites_path(), string_get_cstr(file->name));
|
|
|
|
storage_common_remove(archive->api, string_get_cstr(path));
|
2021-06-25 16:57:42 +00:00
|
|
|
|
|
|
|
if(orig) { // remove original file
|
2021-07-05 12:34:58 +00:00
|
|
|
string_printf(
|
|
|
|
path, "%s/%s", get_default_path(file->type), string_get_cstr(file->name));
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
storage_common_remove(archive->api, string_get_cstr(path));
|
2021-06-25 16:57:42 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
string_clear(path);
|
|
|
|
archive_get_filenames(archive);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
model->idx = CLAMP(model->idx, files_array_size(model->files) - 1, 0);
|
|
|
|
return true;
|
|
|
|
});
|
2021-06-25 16:57:42 +00:00
|
|
|
|
|
|
|
update_offset(archive);
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_file_menu_callback(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
ArchiveFile_t* selected;
|
|
|
|
uint8_t idx = 0;
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
selected = files_array_get(model->files, model->idx);
|
|
|
|
idx = model->menu_idx;
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:54:56 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
switch(idx) {
|
2021-05-18 18:54:56 +00:00
|
|
|
case 0:
|
2021-06-25 16:57:42 +00:00
|
|
|
if(is_known_app(selected->type)) {
|
2021-06-02 12:51:05 +00:00
|
|
|
string_t full_path;
|
2021-07-05 12:34:58 +00:00
|
|
|
string_init_printf(
|
|
|
|
full_path,
|
|
|
|
"%s/%s",
|
|
|
|
string_get_cstr(archive->browser.path),
|
|
|
|
string_get_cstr(selected->name));
|
2021-06-02 12:51:05 +00:00
|
|
|
|
2021-05-26 16:23:25 +00:00
|
|
|
archive_open_app(
|
2021-06-02 12:51:05 +00:00
|
|
|
archive, flipper_app_name[selected->type], string_get_cstr(full_path));
|
|
|
|
|
|
|
|
string_clear(full_path);
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-06-25 16:57:42 +00:00
|
|
|
if(is_known_app(selected->type)) {
|
2021-07-18 18:09:00 +00:00
|
|
|
if(!is_favorite(archive, selected)) {
|
2021-06-25 16:57:42 +00:00
|
|
|
string_set(archive->browser.name, selected->name);
|
2021-07-18 18:09:00 +00:00
|
|
|
archive_add_to_favorites(archive);
|
2021-06-25 16:57:42 +00:00
|
|
|
} else {
|
2021-07-18 18:09:00 +00:00
|
|
|
// delete from favorites
|
2021-06-25 16:57:42 +00:00
|
|
|
archive_delete_file(archive, selected, true, false);
|
|
|
|
}
|
|
|
|
archive_close_file_menu(archive);
|
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// open rename view
|
2021-06-25 16:57:42 +00:00
|
|
|
if(is_known_app(selected->type)) {
|
|
|
|
archive_enter_text_input(archive);
|
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// confirmation?
|
2021-07-18 18:09:00 +00:00
|
|
|
if(is_favorite(archive, selected)) {
|
2021-06-25 16:57:42 +00:00
|
|
|
//delete both fav & original
|
|
|
|
archive_delete_file(archive, selected, true, true);
|
|
|
|
} else {
|
|
|
|
archive_delete_file(archive, selected, false, false);
|
|
|
|
}
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
archive_close_file_menu(archive);
|
2021-06-25 16:57:42 +00:00
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
archive_close_file_menu(archive);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
selected = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void menu_input_handler(ArchiveApp* archive, InputEvent* event) {
|
|
|
|
furi_assert(archive);
|
|
|
|
furi_assert(archive);
|
|
|
|
|
|
|
|
if(event->type == InputTypeShort) {
|
2021-06-23 21:46:52 +00:00
|
|
|
if(event->key == InputKeyUp || event->key == InputKeyDown) {
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
if(event->key == InputKeyUp) {
|
2021-06-25 16:57:42 +00:00
|
|
|
model->menu_idx = ((model->menu_idx - 1) + MENU_ITEMS) % MENU_ITEMS;
|
2021-06-23 21:46:52 +00:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2021-06-25 16:57:42 +00:00
|
|
|
model->menu_idx = (model->menu_idx + 1) % MENU_ITEMS;
|
2021-06-23 21:46:52 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyOk) {
|
2021-05-18 18:54:56 +00:00
|
|
|
archive_file_menu_callback(archive);
|
|
|
|
} else if(event->key == InputKeyBack) {
|
|
|
|
archive_close_file_menu(archive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* main controls */
|
|
|
|
|
|
|
|
static bool archive_view_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
ArchiveApp* archive = context;
|
|
|
|
bool in_menu = archive->browser.menu;
|
|
|
|
|
|
|
|
if(in_menu) {
|
|
|
|
menu_input_handler(archive, event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(event->key == InputKeyLeft) {
|
2021-06-25 16:57:42 +00:00
|
|
|
if(archive->browser.tab_id > 0) {
|
|
|
|
archive->browser.tab_id = CLAMP(archive->browser.tab_id - 1, ArchiveTabTotal, 0);
|
|
|
|
archive_switch_tab(archive);
|
|
|
|
return true;
|
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
} else if(event->key == InputKeyRight) {
|
2021-06-25 16:57:42 +00:00
|
|
|
if(archive->browser.tab_id < ArchiveTabTotal - 1) {
|
|
|
|
archive->browser.tab_id =
|
|
|
|
CLAMP(archive->browser.tab_id + 1, ArchiveTabTotal - 1, 0);
|
|
|
|
archive_switch_tab(archive);
|
|
|
|
return true;
|
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
} else if(event->key == InputKeyBack) {
|
|
|
|
if(archive->browser.depth == 0) {
|
|
|
|
archive_exit_callback(archive);
|
|
|
|
} else {
|
|
|
|
archive_leave_dir(archive);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2021-06-23 21:46:52 +00:00
|
|
|
if(event->key == InputKeyUp || event->key == InputKeyDown) {
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
2021-06-25 16:57:42 +00:00
|
|
|
uint16_t num_elements = (uint16_t)files_array_size(model->files);
|
2021-06-23 21:46:52 +00:00
|
|
|
if((event->type == InputTypeShort || event->type == InputTypeRepeat)) {
|
|
|
|
if(event->key == InputKeyUp) {
|
2021-06-25 16:57:42 +00:00
|
|
|
model->idx = ((model->idx - 1) + num_elements) % num_elements;
|
2021-06-23 21:46:52 +00:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2021-06-25 16:57:42 +00:00
|
|
|
model->idx = (model->idx + 1) % num_elements;
|
2021-06-23 21:46:52 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-25 16:57:42 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
update_offset(archive);
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyOk) {
|
2021-06-23 21:46:52 +00:00
|
|
|
ArchiveFile_t* selected;
|
2021-07-01 16:35:57 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
2021-07-01 16:35:57 +00:00
|
|
|
selected = files_array_size(model->files) > 0 ?
|
|
|
|
files_array_get(model->files, model->idx) :
|
|
|
|
NULL;
|
2021-06-23 21:46:52 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2021-07-01 16:35:57 +00:00
|
|
|
if(selected) {
|
|
|
|
string_set(archive->browser.name, selected->name);
|
|
|
|
|
|
|
|
if(selected->type == ArchiveFileTypeFolder) {
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
archive_enter_dir(archive, archive->browser.name);
|
|
|
|
} else if(event->type == InputTypeLong) {
|
|
|
|
archive_show_file_menu(archive);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
archive_show_file_menu(archive);
|
|
|
|
}
|
2021-05-18 18:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
update_offset(archive);
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_free(ArchiveApp* archive) {
|
|
|
|
furi_assert(archive);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
view_dispatcher_remove_view(archive->view_dispatcher, ArchiveViewMain);
|
|
|
|
view_dispatcher_remove_view(archive->view_dispatcher, ArchiveViewTextInput);
|
|
|
|
view_dispatcher_free(archive->view_dispatcher);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
files_array_clear(model->files);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
view_free(archive->view_archive_main);
|
2021-05-19 09:06:51 +00:00
|
|
|
|
|
|
|
string_clear(archive->browser.name);
|
|
|
|
string_clear(archive->browser.path);
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
text_input_free(archive->text_input);
|
|
|
|
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
furi_record_close("storage");
|
|
|
|
archive->api = NULL;
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_record_close("gui");
|
|
|
|
archive->gui = NULL;
|
2021-07-18 18:09:00 +00:00
|
|
|
furi_record_close("loader");
|
|
|
|
archive->loader = NULL;
|
2021-05-18 18:54:56 +00:00
|
|
|
furi_thread_free(archive->app_thread);
|
2021-05-19 09:06:51 +00:00
|
|
|
furi_check(osMessageQueueDelete(archive->event_queue) == osOK);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
free(archive);
|
|
|
|
}
|
|
|
|
|
|
|
|
ArchiveApp* archive_alloc() {
|
|
|
|
ArchiveApp* archive = furi_alloc(sizeof(ArchiveApp));
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
archive->event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL);
|
2021-05-18 18:54:56 +00:00
|
|
|
archive->app_thread = furi_thread_alloc();
|
|
|
|
archive->gui = furi_record_open("gui");
|
2021-07-18 18:09:00 +00:00
|
|
|
archive->loader = furi_record_open("loader");
|
[FL-1191][FL-1524] Filesystem rework (#568)
* FS-Api: removed datetime manipulation functions and most of the file flags
* Filesystem: common proxy api
* Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance.
* Storage: sd mount and sd file open
* Storage: sd file close
* Storage: temporary test app
* Storage: free filedata on close
* Storage: sd file read and write
* Storage: added internal storage (LittleFS)
* Storage: renamed internal commands
* Storage: seek, tell, truncate, size, sync, eof
* Storage: error descriptions
* Storage: directory management api (open, close, read, rewind)
* Storage: common management api (stat, fs_stat, remove, rename, mkdir)
* Dolphin app and Notifications app now use raw storage.
* Storage: storage statuses renamed. Implemented sd card icon.
* Storage: added raw sd-card api.
* Storage settings: work started
* Assets: use new icons approach
* Storage settings: working storage settings
* Storage: completely redesigned api, no longer sticking out FS_Api
* Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file
* Storage: cli info and format commands
* Storage-cli: file list
* Storage: a simpler and more reliable api
* FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service.
* Storage-cli: accommodate to the new cli api.
* Storage: filesystem api is separated into internal and common api.
* Cli: added the ability to print the list of free heap blocks
* Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags.
* Storage settings: added the ability to benchmark the SD card.
* Gui module file select: uses new storage api
* Apps: removed deprecated sd_card_test application
* Args lib: support for enquoted arguments
* Dialogs: a new gui app for simple non-asynchronous apps
* Dialogs: view holder for easy single view work
* File worker: use new storage api
* IButton and lfrrfid apps: save keys to any storage
* Apps: fix ibutton and lfrfid stack, remove sd_card_test.
* SD filesystem: app removed
* File worker: fixed api pointer type
* Subghz: loading assets using the new storage api
* NFC: use the new storage api
* Dialogs: the better api for the message element
* Archive: use new storage api
* Irda: changed assest path, changed app path
* FileWorker: removed unused file_buf_cnt
* Storage: copying and renaming files now works between storages
* Storage cli: read, copy, remove, rename commands
* Archive: removed commented code
* Storage cli: write command
* Applications: add SRV_STORAGE and SRV_DIALOGS
* Internal-storage: removed
* Storage: improved api
* Storage app: changed api pointer from StorageApp to Storage
* Storage: better file_id handling
* Storage: more consistent errors
* Loader: support for NULL icons
* Storage: do nothing with the lfs file or directory if it is not open
* Storage: fix typo
* Storage: minor float usage cleanup, rename some symbols.
* Storage: compact doxygen comments.
Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 12:20:19 +00:00
|
|
|
archive->api = furi_record_open("storage");
|
2021-05-18 18:54:56 +00:00
|
|
|
archive->text_input = text_input_alloc();
|
|
|
|
archive->view_archive_main = view_alloc();
|
|
|
|
|
|
|
|
furi_check(archive->event_queue);
|
|
|
|
|
|
|
|
view_allocate_model(
|
2021-06-23 21:46:52 +00:00
|
|
|
archive->view_archive_main, ViewModelTypeLocking, sizeof(ArchiveViewModel));
|
|
|
|
with_view_model(
|
|
|
|
archive->view_archive_main, (ArchiveViewModel * model) {
|
|
|
|
files_array_init(model->files);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
view_set_context(archive->view_archive_main, archive);
|
|
|
|
view_set_draw_callback(archive->view_archive_main, archive_view_render);
|
|
|
|
view_set_input_callback(archive->view_archive_main, archive_view_input);
|
|
|
|
view_set_previous_callback(
|
|
|
|
text_input_get_view(archive->text_input), archive_previous_callback);
|
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
// View Dispatcher
|
|
|
|
archive->view_dispatcher = view_dispatcher_alloc();
|
2021-05-18 18:54:56 +00:00
|
|
|
view_dispatcher_add_view(
|
|
|
|
archive->view_dispatcher, ArchiveViewMain, archive->view_archive_main);
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
archive->view_dispatcher, ArchiveViewTextInput, text_input_get_view(archive->text_input));
|
|
|
|
view_dispatcher_attach_to_gui(
|
|
|
|
archive->view_dispatcher, archive->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveTabFavorites);
|
2021-05-18 18:54:56 +00:00
|
|
|
|
|
|
|
return archive;
|
|
|
|
}
|
|
|
|
|
2021-08-07 16:54:42 +00:00
|
|
|
int32_t archive_app(void* p) {
|
2021-05-18 18:54:56 +00:00
|
|
|
ArchiveApp* archive = archive_alloc();
|
|
|
|
|
|
|
|
// default tab
|
|
|
|
archive_switch_tab(archive);
|
|
|
|
|
|
|
|
AppEvent event;
|
|
|
|
while(1) {
|
|
|
|
furi_check(osMessageQueueGet(archive->event_queue, &event, NULL, osWaitForever) == osOK);
|
|
|
|
if(event.type == EventTypeExit) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
archive_free(archive);
|
|
|
|
return 0;
|
|
|
|
}
|