mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Improve filter options, fix deleting directories containing directories.
This commit is contained in:
parent
b85389c43c
commit
0e4d2ff0e4
@ -29,7 +29,7 @@ static void action_delete_contents_draw_top(ui_view* view, void* data, float x1,
|
||||
|
||||
u32 curr = deleteData->deleteInfo.processed;
|
||||
if(curr < deleteData->deleteInfo.total) {
|
||||
ui_draw_file_info(view, ((list_item*) linked_list_get(&deleteData->contents, curr))->data, x1, y1, x2, y2);
|
||||
ui_draw_file_info(view, ((list_item*) linked_list_get(&deleteData->contents, linked_list_size(&deleteData->contents) - curr - 1))->data, x1, y1, x2, y2);
|
||||
} else if(deleteData->target != NULL) {
|
||||
ui_draw_file_info(view, deleteData->target, x1, y1, x2, y2);
|
||||
}
|
||||
@ -40,7 +40,7 @@ static Result action_delete_contents_delete(void* data, u32 index) {
|
||||
|
||||
Result res = 0;
|
||||
|
||||
file_info* info = (file_info*) ((list_item*) linked_list_get(&deleteData->contents, index))->data;
|
||||
file_info* info = (file_info*) ((list_item*) linked_list_get(&deleteData->contents, linked_list_size(&deleteData->contents) - index - 1))->data;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(info->path);
|
||||
if(fsPath != NULL) {
|
||||
@ -114,7 +114,7 @@ static void action_delete_contents_update(ui_view* view, void* data, float* prog
|
||||
info_destroy(view);
|
||||
|
||||
if(R_SUCCEEDED(deleteData->deleteInfo.result)) {
|
||||
prompt_display("Success", "Contents deleted.", COLOR_TEXT, false, NULL, NULL, NULL, NULL);
|
||||
prompt_display("Success", "Deleted.", COLOR_TEXT, false, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
action_delete_contents_free_data(deleteData);
|
||||
@ -136,7 +136,7 @@ static void action_delete_contents_onresponse(ui_view* view, void* data, bool re
|
||||
if(response) {
|
||||
Result res = task_data_op(&deleteData->deleteInfo);
|
||||
if(R_SUCCEEDED(res)) {
|
||||
info_display("Deleting Contents", "Press B to cancel.", true, data, action_delete_contents_update, action_delete_contents_draw_top);
|
||||
info_display("Deleting", "Press B to cancel.", true, data, action_delete_contents_update, action_delete_contents_draw_top);
|
||||
} else {
|
||||
error_display_res(NULL, deleteData->target, ui_draw_file_info, res, "Failed to initiate delete operation.");
|
||||
|
||||
@ -150,7 +150,7 @@ static void action_delete_contents_onresponse(ui_view* view, void* data, bool re
|
||||
static void action_delete_contents_internal(linked_list* items, list_item* selected, const char* message, bool recursive, bool includeBase, bool ciasOnly, bool ticketsOnly) {
|
||||
delete_contents_data* data = (delete_contents_data*) calloc(1, sizeof(delete_contents_data));
|
||||
if(data == NULL) {
|
||||
error_display(NULL, NULL, NULL, "Failed to allocate delete contents data.");
|
||||
error_display(NULL, NULL, NULL, "Failed to allocate delete data.");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -175,7 +175,6 @@ static void action_delete_contents_internal(linked_list* items, list_item* selec
|
||||
popData.base = data->target;
|
||||
popData.recursive = recursive;
|
||||
popData.includeBase = includeBase;
|
||||
popData.dirsFirst = false;
|
||||
popData.filter = ciasOnly ? util_filter_cias : ticketsOnly ? util_filter_tickets : NULL;
|
||||
popData.filterData = NULL;
|
||||
|
||||
|
@ -282,7 +282,6 @@ static void action_install_cias_internal(linked_list* items, list_item* selected
|
||||
popData.base = data->target;
|
||||
popData.recursive = false;
|
||||
popData.includeBase = !data->target->isDirectory;
|
||||
popData.dirsFirst = false;
|
||||
popData.filter = util_filter_cias;
|
||||
popData.filterData = NULL;
|
||||
|
||||
|
@ -261,7 +261,6 @@ static void action_install_tickets_internal(linked_list* items, list_item* selec
|
||||
popData.base = data->target;
|
||||
popData.recursive = false;
|
||||
popData.includeBase = !data->target->isDirectory;
|
||||
popData.dirsFirst = false;
|
||||
popData.filter = util_filter_tickets;
|
||||
popData.filterData = NULL;
|
||||
|
||||
|
@ -313,7 +313,6 @@ void action_paste_contents(linked_list* items, list_item* selected) {
|
||||
popData.base = (file_info*) clipboardItem->data;
|
||||
popData.recursive = true;
|
||||
popData.includeBase = !clipboard_is_contents_only() || !util_is_dir(clipboard_get_archive(), clipboard_get_path());
|
||||
popData.dirsFirst = true;
|
||||
popData.filter = NULL;
|
||||
popData.filterData = NULL;
|
||||
|
||||
|
@ -48,10 +48,11 @@ typedef struct {
|
||||
FS_Path archivePath;
|
||||
FS_Archive archive;
|
||||
|
||||
bool showHidden;
|
||||
bool showDirectories;
|
||||
bool showFiles;
|
||||
bool showCias;
|
||||
bool showTickets;
|
||||
bool showMisc;
|
||||
|
||||
char currDir[FILE_PATH_MAX];
|
||||
list_item* dirItem;
|
||||
@ -196,10 +197,11 @@ static void files_filters_update(ui_view* view, void* data, linked_list* items,
|
||||
}
|
||||
|
||||
if(linked_list_size(items) == 0) {
|
||||
files_filters_add_entry(items, "Show hidden", &listData->showHidden);
|
||||
files_filters_add_entry(items, "Show directories", &listData->showDirectories);
|
||||
files_filters_add_entry(items, "Show files", &listData->showFiles);
|
||||
files_filters_add_entry(items, "Show CIAs", &listData->showCias);
|
||||
files_filters_add_entry(items, "Show tickets", &listData->showTickets);
|
||||
files_filters_add_entry(items, "Show miscellaneous", &listData->showMisc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,21 +338,23 @@ static void files_update(ui_view* view, void* data, linked_list* items, list_ite
|
||||
static bool files_filter(void* data, const char* name, u32 attributes) {
|
||||
files_data* listData = (files_data*) data;
|
||||
|
||||
if((attributes & FS_ATTRIBUTE_HIDDEN) != 0 && !listData->showHidden) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if((attributes & FS_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
return listData->showDirectories;
|
||||
} else {
|
||||
size_t len = strlen(name);
|
||||
if(len >= 4) {
|
||||
const char* extension = name + len - 4;
|
||||
if(strncasecmp(extension, ".cia", 4) == 0) {
|
||||
return listData->showCias;
|
||||
} else if(strncasecmp(extension, ".tik", 4) == 0) {
|
||||
return listData->showTickets;
|
||||
if((strncasecmp(extension, ".cia", 4) == 0 && !listData->showCias) || (strncasecmp(extension, ".tik", 4) == 0 && !listData->showTickets)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return listData->showMisc;
|
||||
return listData->showFiles;
|
||||
}
|
||||
}
|
||||
|
||||
void files_open(FS_ArchiveID archiveId, FS_Path archivePath) {
|
||||
@ -363,7 +367,6 @@ void files_open(FS_ArchiveID archiveId, FS_Path archivePath) {
|
||||
|
||||
data->populateData.recursive = false;
|
||||
data->populateData.includeBase = false;
|
||||
data->populateData.dirsFirst = true;
|
||||
|
||||
data->populateData.filter = files_filter;
|
||||
data->populateData.filterData = data;
|
||||
@ -372,10 +375,11 @@ void files_open(FS_ArchiveID archiveId, FS_Path archivePath) {
|
||||
|
||||
data->populated = false;
|
||||
|
||||
data->showHidden = false;
|
||||
data->showDirectories = true;
|
||||
data->showFiles = true;
|
||||
data->showCias = true;
|
||||
data->showTickets = true;
|
||||
data->showMisc = true;
|
||||
|
||||
data->archiveId = archiveId;
|
||||
data->archivePath.type = archivePath.type;
|
||||
|
@ -164,7 +164,7 @@ static void task_populate_files_thread(void* arg) {
|
||||
file_info* curr = (file_info*) currItem->data;
|
||||
linked_list_remove_at(&queue, tail);
|
||||
|
||||
if(data->dirsFirst && (data->includeBase || currItem != baseItem)) {
|
||||
if(data->includeBase || currItem != baseItem) {
|
||||
linked_list_add(data->items, currItem);
|
||||
}
|
||||
|
||||
@ -186,10 +186,6 @@ static void task_populate_files_thread(void* arg) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(entries[i].attributes & FS_ATTRIBUTE_HIDDEN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char name[FILE_NAME_MAX] = {'\0'};
|
||||
utf16_to_utf8((uint8_t*) name, entries[i].name, FILE_NAME_MAX - 1);
|
||||
|
||||
@ -199,7 +195,7 @@ static void task_populate_files_thread(void* arg) {
|
||||
|
||||
list_item* item = NULL;
|
||||
if(R_SUCCEEDED(res = task_create_file_item(&item, curr->archive, path))) {
|
||||
if(curr->isDirectory && strncmp(curr->path, data->base->path, FILE_PATH_MAX) == 0) {
|
||||
if(currItem == baseItem) {
|
||||
file_info* info = (file_info*) item->data;
|
||||
|
||||
if(info->isCia) {
|
||||
@ -232,10 +228,6 @@ static void task_populate_files_thread(void* arg) {
|
||||
res = R_FBI_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if(!data->dirsFirst && (data->includeBase || currItem != baseItem)) {
|
||||
linked_list_add(data->items, currItem);
|
||||
}
|
||||
}
|
||||
|
||||
if(!data->includeBase) {
|
||||
|
@ -145,7 +145,6 @@ typedef struct {
|
||||
|
||||
bool recursive;
|
||||
bool includeBase;
|
||||
bool dirsFirst;
|
||||
|
||||
bool (*filter)(void* data, const char* name, u32 attributes);
|
||||
void* filterData;
|
||||
|
Loading…
x
Reference in New Issue
Block a user