[FL-2216, FL-2233] Archive fixes (#987)
* archive: badusb, u2f and various fixes * archive: delete confirmation * badusb: removed empty string check * string pointer check * FuriHal: insomnia overflow assert, fix double insomnia exit in ble. BadUsb: fix uncommitted model. * view update fixes in gpio, badusb, u2f Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
74
applications/archive/helpers/archive_apps.c
Normal file
74
applications/archive/helpers/archive_apps.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "archive_files.h"
|
||||
#include "archive_apps.h"
|
||||
#include "archive_browser.h"
|
||||
|
||||
static const char* known_apps[] = {
|
||||
[ArchiveAppTypeU2f] = "u2f",
|
||||
};
|
||||
|
||||
ArchiveAppTypeEnum archive_get_app_type(const char* path) {
|
||||
for(size_t i = 0; i < SIZEOF_ARRAY(known_apps); i++) {
|
||||
if(strncmp(path, known_apps[i], strlen(known_apps[i])) != STRING_FAILURE) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return ArchiveAppTypeUnknown;
|
||||
}
|
||||
|
||||
bool archive_app_is_available(void* context, const char* path) {
|
||||
furi_assert(path);
|
||||
|
||||
ArchiveAppTypeEnum app = archive_get_app_type(path);
|
||||
|
||||
if(app == ArchiveAppTypeU2f) {
|
||||
FileWorker* file_worker = file_worker_alloc(true);
|
||||
bool file_exists = false;
|
||||
file_worker_is_file_exist(file_worker, "/any/u2f/key.u2f", &file_exists);
|
||||
if(file_exists) {
|
||||
file_worker_is_file_exist(file_worker, "/any/u2f/cnt.u2f", &file_exists);
|
||||
}
|
||||
file_worker_free(file_worker);
|
||||
return file_exists;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool archive_app_read_dir(void* context, const char* path) {
|
||||
furi_assert(context);
|
||||
furi_assert(path);
|
||||
ArchiveBrowserView* browser = context;
|
||||
|
||||
ArchiveAppTypeEnum app = archive_get_app_type(path);
|
||||
|
||||
if(app == ArchiveAppTypeU2f) {
|
||||
archive_add_app_item(browser, "/app:u2f/U2F Token");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void archive_app_delete_file(void* context, const char* path) {
|
||||
furi_assert(context);
|
||||
furi_assert(path);
|
||||
ArchiveBrowserView* browser = context;
|
||||
|
||||
ArchiveAppTypeEnum app = archive_get_app_type(path);
|
||||
bool res = false;
|
||||
|
||||
if(app == ArchiveAppTypeU2f) {
|
||||
FileWorker* file_worker = file_worker_alloc(true);
|
||||
res = file_worker_remove(file_worker, "/any/u2f/key.u2f");
|
||||
res |= file_worker_remove(file_worker, "/any/u2f/cnt.u2f");
|
||||
file_worker_free(file_worker);
|
||||
|
||||
if(archive_is_favorite("/app:u2f/U2F Token")) {
|
||||
archive_favorites_delete("/app:u2f/U2F Token");
|
||||
}
|
||||
}
|
||||
|
||||
if(res) {
|
||||
archive_file_array_rm_selected(browser);
|
||||
}
|
||||
}
|
21
applications/archive/helpers/archive_apps.h
Normal file
21
applications/archive/helpers/archive_apps.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
ArchiveAppTypeU2f,
|
||||
ArchiveAppTypeUnknown,
|
||||
ArchiveAppsTotal,
|
||||
} ArchiveAppTypeEnum;
|
||||
|
||||
static const ArchiveFileTypeEnum app_file_types[] = {
|
||||
[ArchiveAppTypeU2f] = ArchiveFileTypeU2f,
|
||||
[ArchiveAppTypeUnknown] = ArchiveFileTypeUnknown,
|
||||
};
|
||||
|
||||
static inline const ArchiveFileTypeEnum archive_get_app_filetype(ArchiveAppTypeEnum app) {
|
||||
return app_file_types[app];
|
||||
}
|
||||
|
||||
ArchiveAppTypeEnum archive_get_app_type(const char* path);
|
||||
bool archive_app_is_available(void* context, const char* path);
|
||||
bool archive_app_read_dir(void* context, const char* path);
|
||||
void archive_app_delete_file(void* context, const char* path);
|
@@ -1,5 +1,7 @@
|
||||
#include "archive_files.h"
|
||||
#include "archive_apps.h"
|
||||
#include "archive_browser.h"
|
||||
#include "math.h"
|
||||
#include <math.h>
|
||||
|
||||
void archive_update_offset(ArchiveBrowserView* browser) {
|
||||
furi_assert(browser);
|
||||
@@ -177,24 +179,53 @@ void archive_set_last_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
|
||||
});
|
||||
}
|
||||
|
||||
void archive_add_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name) {
|
||||
void archive_add_app_item(ArchiveBrowserView* browser, const char* name) {
|
||||
furi_assert(browser);
|
||||
furi_assert(name);
|
||||
|
||||
ArchiveFile_t item;
|
||||
|
||||
string_t full_name;
|
||||
|
||||
string_init_set(full_name, browser->path);
|
||||
string_cat_printf(full_name, "/%s", name);
|
||||
|
||||
char* app_name = strchr(string_get_cstr(full_name), ':');
|
||||
if(app_name == NULL) {
|
||||
string_clear(full_name);
|
||||
return;
|
||||
}
|
||||
|
||||
ArchiveFile_t_init(&item);
|
||||
string_init_set_str(item.name, name);
|
||||
set_file_type(&item, NULL, app_name + 1, true);
|
||||
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
files_array_push_back(model->files, item);
|
||||
return false;
|
||||
});
|
||||
ArchiveFile_t_clear(&item);
|
||||
string_clear(full_name);
|
||||
}
|
||||
|
||||
void archive_add_file_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name) {
|
||||
furi_assert(browser);
|
||||
furi_assert(file_info);
|
||||
furi_assert(name);
|
||||
|
||||
ArchiveFile_t item;
|
||||
|
||||
if(filter_by_extension(file_info, get_tab_ext(archive_get_tab(browser)), name)) {
|
||||
if(filter_by_extension(file_info, archive_get_tab_ext(archive_get_tab(browser)), name)) {
|
||||
ArchiveFile_t_init(&item);
|
||||
string_init_set_str(item.name, name);
|
||||
set_file_type(&item, file_info);
|
||||
set_file_type(&item, file_info, archive_get_path(browser), false);
|
||||
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
files_array_push_back(model->files, item);
|
||||
return false;
|
||||
});
|
||||
|
||||
ArchiveFile_t_clear(&item);
|
||||
}
|
||||
}
|
||||
@@ -208,8 +239,7 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show) {
|
||||
|
||||
if(show) {
|
||||
ArchiveFile_t* selected = files_array_get(model->files, model->idx);
|
||||
selected->fav = archive_is_favorite(
|
||||
"%s/%s", string_get_cstr(browser->path), string_get_cstr(selected->name));
|
||||
selected->fav = archive_is_favorite("%s", string_get_cstr(selected->name));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -245,12 +275,18 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
|
||||
|
||||
archive_set_tab(browser, tab);
|
||||
|
||||
if((tab != ArchiveTabFavorites &&
|
||||
!archive_dir_empty(browser, archive_get_default_path(tab))) ||
|
||||
(tab == ArchiveTabFavorites && !archive_favorites_count(browser))) {
|
||||
if(tab != ArchiveTabBrowser) {
|
||||
archive_switch_tab(browser, key);
|
||||
}
|
||||
const char* path = archive_get_default_path(tab);
|
||||
bool tab_empty = true;
|
||||
if(tab == ArchiveTabFavorites) {
|
||||
if(archive_favorites_count(browser) > 0) tab_empty = false;
|
||||
} else if(strncmp(path, "/app:", 5) == 0) {
|
||||
if(archive_app_is_available(browser, path)) tab_empty = false;
|
||||
} else {
|
||||
if(archive_dir_not_empty(browser, archive_get_default_path(tab))) tab_empty = false;
|
||||
}
|
||||
|
||||
if((tab_empty) && (tab != ArchiveTabBrowser)) {
|
||||
archive_switch_tab(browser, key);
|
||||
} else {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
@@ -277,8 +313,7 @@ void archive_enter_dir(ArchiveBrowserView* browser, string_t name) {
|
||||
return false;
|
||||
});
|
||||
|
||||
string_cat(browser->path, "/");
|
||||
string_cat(browser->path, name);
|
||||
string_set(browser->path, name);
|
||||
|
||||
archive_switch_dir(browser, string_get_cstr(browser->path));
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ static const char* tab_default_paths[] = {
|
||||
[ArchiveTabSubGhz] = "/any/subghz",
|
||||
[ArchiveTabLFRFID] = "/any/lfrfid",
|
||||
[ArchiveTabIrda] = "/any/irda",
|
||||
[ArchiveTabBadUsb] = "/any/badusb",
|
||||
[ArchiveTabU2f] = "/app:u2f",
|
||||
[ArchiveTabBrowser] = "/any",
|
||||
};
|
||||
|
||||
@@ -20,30 +22,37 @@ static const char* known_ext[] = {
|
||||
[ArchiveFileTypeSubGhz] = ".sub",
|
||||
[ArchiveFileTypeLFRFID] = ".rfid",
|
||||
[ArchiveFileTypeIrda] = ".ir",
|
||||
[ArchiveFileTypeBadUsb] = ".txt",
|
||||
[ArchiveFileTypeU2f] = "?",
|
||||
[ArchiveFileTypeFolder] = "?",
|
||||
[ArchiveFileTypeUnknown] = "*",
|
||||
};
|
||||
|
||||
static inline const char* get_tab_ext(ArchiveTabEnum tab) {
|
||||
switch(tab) {
|
||||
case ArchiveTabIButton:
|
||||
return known_ext[ArchiveFileTypeIButton];
|
||||
case ArchiveTabNFC:
|
||||
return known_ext[ArchiveFileTypeNFC];
|
||||
case ArchiveTabSubGhz:
|
||||
return known_ext[ArchiveFileTypeSubGhz];
|
||||
case ArchiveTabLFRFID:
|
||||
return known_ext[ArchiveFileTypeLFRFID];
|
||||
case ArchiveTabIrda:
|
||||
return known_ext[ArchiveFileTypeIrda];
|
||||
default:
|
||||
return "*";
|
||||
}
|
||||
static const ArchiveFileTypeEnum known_type[] = {
|
||||
[ArchiveTabFavorites] = ArchiveFileTypeUnknown,
|
||||
[ArchiveTabIButton] = ArchiveFileTypeIButton,
|
||||
[ArchiveTabNFC] = ArchiveFileTypeNFC,
|
||||
[ArchiveTabSubGhz] = ArchiveFileTypeSubGhz,
|
||||
[ArchiveTabLFRFID] = ArchiveFileTypeLFRFID,
|
||||
[ArchiveTabIrda] = ArchiveFileTypeIrda,
|
||||
[ArchiveTabBadUsb] = ArchiveFileTypeBadUsb,
|
||||
[ArchiveTabU2f] = ArchiveFileTypeU2f,
|
||||
[ArchiveTabBrowser] = ArchiveFileTypeUnknown,
|
||||
};
|
||||
|
||||
static inline const ArchiveFileTypeEnum archive_get_tab_filetype(ArchiveTabEnum tab) {
|
||||
return known_type[tab];
|
||||
}
|
||||
|
||||
static inline const char* archive_get_tab_ext(ArchiveTabEnum tab) {
|
||||
return known_ext[archive_get_tab_filetype(tab)];
|
||||
}
|
||||
|
||||
static inline const char* archive_get_default_path(ArchiveTabEnum tab) {
|
||||
return tab_default_paths[tab];
|
||||
}
|
||||
|
||||
inline bool is_known_app(ArchiveFileTypeEnum type) {
|
||||
inline bool archive_is_known_app(ArchiveFileTypeEnum type) {
|
||||
return (type != ArchiveFileTypeFolder && type != ArchiveFileTypeUnknown);
|
||||
}
|
||||
|
||||
@@ -62,7 +71,8 @@ uint8_t archive_get_depth(ArchiveBrowserView* browser);
|
||||
const char* archive_get_path(ArchiveBrowserView* browser);
|
||||
const char* archive_get_name(ArchiveBrowserView* browser);
|
||||
|
||||
void archive_add_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name);
|
||||
void archive_add_app_item(ArchiveBrowserView* browser, const char* name);
|
||||
void archive_add_file_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name);
|
||||
void archive_show_file_menu(ArchiveBrowserView* browser, bool show);
|
||||
void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active);
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
|
||||
#include "archive_favorites.h"
|
||||
#include "archive_files.h"
|
||||
#include "archive_apps.h"
|
||||
#include "archive_browser.h"
|
||||
|
||||
uint16_t archive_favorites_count(void* context) {
|
||||
@@ -46,10 +48,16 @@ static bool archive_favourites_rescan() {
|
||||
break;
|
||||
}
|
||||
|
||||
bool file_exists = false;
|
||||
file_worker_is_file_exist(file_worker, string_get_cstr(buffer), &file_exists);
|
||||
if(file_exists) {
|
||||
archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
|
||||
if(string_search(buffer, "/app:") == 0) {
|
||||
if(archive_app_is_available(NULL, string_get_cstr(buffer))) {
|
||||
archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
|
||||
}
|
||||
} else {
|
||||
bool file_exists = false;
|
||||
file_worker_is_file_exist(file_worker, string_get_cstr(buffer), &file_exists);
|
||||
if(file_exists) {
|
||||
archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,13 +96,22 @@ bool archive_favorites_read(void* context) {
|
||||
break;
|
||||
}
|
||||
|
||||
bool file_exists = false;
|
||||
file_worker_is_file_exist(file_worker, string_get_cstr(buffer), &file_exists);
|
||||
if(string_search(buffer, "/app:") == 0) {
|
||||
if(archive_app_is_available(browser, string_get_cstr(buffer))) {
|
||||
archive_add_app_item(browser, string_get_cstr(buffer));
|
||||
} else {
|
||||
need_refresh = true;
|
||||
}
|
||||
} else {
|
||||
bool file_exists = false;
|
||||
file_worker_is_file_exist(file_worker, string_get_cstr(buffer), &file_exists);
|
||||
|
||||
if(file_exists)
|
||||
archive_add_file_item(browser, &file_info, string_get_cstr(buffer));
|
||||
else
|
||||
need_refresh = true;
|
||||
}
|
||||
|
||||
if(file_exists)
|
||||
archive_add_item(browser, &file_info, string_get_cstr(buffer));
|
||||
else
|
||||
need_refresh = true;
|
||||
string_reset(buffer);
|
||||
}
|
||||
}
|
||||
@@ -185,8 +202,7 @@ bool archive_is_favorite(const char* format, ...) {
|
||||
return found;
|
||||
}
|
||||
|
||||
bool archive_favorites_rename(const char* file_path, const char* src, const char* dst) {
|
||||
furi_assert(file_path);
|
||||
bool archive_favorites_rename(const char* src, const char* dst) {
|
||||
furi_assert(src);
|
||||
furi_assert(dst);
|
||||
|
||||
@@ -198,7 +214,7 @@ bool archive_favorites_rename(const char* file_path, const char* src, const char
|
||||
string_init(buffer);
|
||||
string_init(path);
|
||||
|
||||
string_printf(path, "%s/%s", file_path, src);
|
||||
string_printf(path, "%s", src);
|
||||
bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||
|
||||
if(result) {
|
||||
|
@@ -8,6 +8,6 @@ uint16_t archive_favorites_count(void* context);
|
||||
bool archive_favorites_read(void* context);
|
||||
bool archive_favorites_delete(const char* format, ...);
|
||||
bool archive_is_favorite(const char* format, ...);
|
||||
bool archive_favorites_rename(const char* file_path, const char* src, const char* dst);
|
||||
bool archive_favorites_rename(const char* src, const char* dst);
|
||||
void archive_add_to_favorites(const char* file_path);
|
||||
void archive_favorites_save(void* context);
|
||||
|
@@ -1,8 +1,11 @@
|
||||
#include "archive_files.h"
|
||||
#include "archive_apps.h"
|
||||
#include "archive_browser.h"
|
||||
|
||||
#define TAG "Archive"
|
||||
|
||||
#define ASSETS_DIR "assets"
|
||||
|
||||
bool filter_by_extension(FileInfo* file_info, const char* tab_ext, const char* name) {
|
||||
furi_assert(file_info);
|
||||
furi_assert(tab_ext);
|
||||
@@ -15,7 +18,11 @@ bool filter_by_extension(FileInfo* file_info, const char* tab_ext, const char* n
|
||||
} else if(strstr(name, tab_ext) != NULL) {
|
||||
result = true;
|
||||
} else if(file_info->flags & FSF_DIRECTORY) {
|
||||
result = true;
|
||||
if(strstr(name, ASSETS_DIR) != NULL) {
|
||||
result = false; // Skip assets folder in all tabs except browser
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -38,21 +45,36 @@ void archive_get_file_extension(char* name, char* ext) {
|
||||
strncpy(ext, dot, MAX_EXT_LEN);
|
||||
}
|
||||
|
||||
void set_file_type(ArchiveFile_t* file, FileInfo* file_info) {
|
||||
void set_file_type(ArchiveFile_t* file, FileInfo* file_info, const char* path, bool is_app) {
|
||||
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;
|
||||
file->is_app = is_app;
|
||||
if(is_app) {
|
||||
file->type = archive_get_app_filetype(archive_get_app_type(path));
|
||||
} else {
|
||||
file->type = ArchiveFileTypeUnknown;
|
||||
furi_assert(file_info);
|
||||
|
||||
for(size_t i = 0; i < SIZEOF_ARRAY(known_ext); i++) {
|
||||
if((known_ext[i][0] == '?') || (known_ext[i][0] == '*')) continue;
|
||||
if(string_search_str(file->name, known_ext[i], 0) != STRING_FAILURE) {
|
||||
if(i == ArchiveFileTypeBadUsb) {
|
||||
if(string_search_str(file->name, archive_get_default_path(ArchiveTabBadUsb)) ==
|
||||
0) {
|
||||
file->type = i;
|
||||
return; // *.txt file is a BadUSB script only if it is in BadUSB folder
|
||||
}
|
||||
} else {
|
||||
file->type = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(file_info->flags & FSF_DIRECTORY) {
|
||||
file->type = ArchiveFileTypeFolder;
|
||||
} else {
|
||||
file->type = ArchiveFileTypeUnknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,17 +85,21 @@ bool archive_get_filenames(void* context, const char* path) {
|
||||
ArchiveBrowserView* browser = context;
|
||||
archive_file_array_rm_all(browser);
|
||||
|
||||
if(archive_get_tab(browser) != ArchiveTabFavorites) {
|
||||
res = archive_read_dir(browser, path);
|
||||
} else {
|
||||
if(archive_get_tab(browser) == ArchiveTabFavorites) {
|
||||
res = archive_favorites_read(browser);
|
||||
} else if(strncmp(path, "/app:", 5) == 0) {
|
||||
res = archive_app_read_dir(browser, path);
|
||||
} else {
|
||||
res = archive_read_dir(browser, path);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool archive_dir_empty(void* context, const char* path) { // can be simpler?
|
||||
bool archive_dir_not_empty(void* context, const char* path) { // can be simpler?
|
||||
furi_assert(context);
|
||||
|
||||
ArchiveBrowserView* browser = context;
|
||||
|
||||
FileInfo file_info;
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
File* directory = storage_file_alloc(fs_api);
|
||||
@@ -92,8 +118,11 @@ bool archive_dir_empty(void* context, const char* path) { // can be simpler?
|
||||
}
|
||||
if(files_found) {
|
||||
break;
|
||||
} else if(storage_file_get_error(directory) == FSE_OK) {
|
||||
files_found = name[0];
|
||||
} else if((storage_file_get_error(directory) == FSE_OK) && (name[0])) {
|
||||
if(filter_by_extension(
|
||||
&file_info, archive_get_tab_ext(archive_get_tab(browser)), name)) {
|
||||
files_found = true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -114,6 +143,8 @@ bool archive_read_dir(void* context, const char* path) {
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
File* directory = storage_file_alloc(fs_api);
|
||||
char name[MAX_NAME_LEN];
|
||||
snprintf(name, MAX_NAME_LEN, "%s/", path);
|
||||
size_t path_len = strlen(name);
|
||||
size_t files_cnt = 0;
|
||||
|
||||
if(!storage_dir_open(directory, path)) {
|
||||
@@ -123,13 +154,14 @@ bool archive_read_dir(void* context, const char* path) {
|
||||
}
|
||||
|
||||
while(1) {
|
||||
if(!storage_dir_read(directory, &file_info, name, MAX_NAME_LEN)) {
|
||||
if(!storage_dir_read(directory, &file_info, &name[path_len], MAX_NAME_LEN - path_len)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(files_cnt > MAX_FILES) {
|
||||
break;
|
||||
} else if(storage_file_get_error(directory) == FSE_OK) {
|
||||
archive_add_item(browser, &file_info, name);
|
||||
archive_add_file_item(browser, &file_info, name);
|
||||
++files_cnt;
|
||||
} else {
|
||||
storage_dir_close(directory);
|
||||
|
@@ -9,29 +9,38 @@ typedef enum {
|
||||
ArchiveFileTypeSubGhz,
|
||||
ArchiveFileTypeLFRFID,
|
||||
ArchiveFileTypeIrda,
|
||||
ArchiveFileTypeBadUsb,
|
||||
ArchiveFileTypeU2f,
|
||||
ArchiveFileTypeFolder,
|
||||
ArchiveFileTypeUnknown,
|
||||
AppIdTotal,
|
||||
ArchiveFileTypesTotal,
|
||||
} ArchiveFileTypeEnum;
|
||||
|
||||
typedef struct {
|
||||
string_t name;
|
||||
ArchiveFileTypeEnum type;
|
||||
bool fav;
|
||||
bool is_app;
|
||||
} ArchiveFile_t;
|
||||
|
||||
static void ArchiveFile_t_init(ArchiveFile_t* obj) {
|
||||
obj->type = ArchiveFileTypeUnknown;
|
||||
obj->is_app = false;
|
||||
obj->fav = false;
|
||||
string_init(obj->name);
|
||||
}
|
||||
|
||||
static void ArchiveFile_t_init_set(ArchiveFile_t* obj, const ArchiveFile_t* src) {
|
||||
obj->type = src->type;
|
||||
obj->is_app = src->is_app;
|
||||
obj->fav = src->fav;
|
||||
string_init_set(obj->name, src->name);
|
||||
}
|
||||
|
||||
static void ArchiveFile_t_set(ArchiveFile_t* obj, const ArchiveFile_t* src) {
|
||||
obj->type = src->type;
|
||||
obj->is_app = src->is_app;
|
||||
obj->fav = src->fav;
|
||||
string_set(obj->name, src->name);
|
||||
}
|
||||
|
||||
@@ -48,11 +57,11 @@ ARRAY_DEF(
|
||||
CLEAR(API_2(ArchiveFile_t_clear))))
|
||||
|
||||
bool filter_by_extension(FileInfo* file_info, const char* tab_ext, const char* name);
|
||||
void set_file_type(ArchiveFile_t* file, FileInfo* file_info);
|
||||
void set_file_type(ArchiveFile_t* file, FileInfo* file_info, const char* path, bool is_app);
|
||||
void archive_trim_file_path(char* name, bool ext);
|
||||
void archive_get_file_extension(char* name, char* ext);
|
||||
bool archive_get_filenames(void* context, const char* path);
|
||||
bool archive_dir_empty(void* context, const char* path);
|
||||
bool archive_dir_not_empty(void* context, const char* path);
|
||||
bool archive_read_dir(void* context, const char* path);
|
||||
void archive_file_append(const char* path, const char* format, ...);
|
||||
void archive_delete_file(void* context, const char* format, ...);
|
Reference in New Issue
Block a user