mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Copy attributes when pasting.
This commit is contained in:
parent
d281bef26e
commit
5d014fd748
@ -32,7 +32,7 @@ void action_new_folder(linked_list* items, list_item* selected) {
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_CreateDirectory(parentDir->archive, *fsPath, 0);
|
||||
res = FSUSER_CreateDirectory(parentDir->archive, *fsPath, FS_ATTRIBUTE_DIRECTORY);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
} else {
|
||||
@ -41,7 +41,7 @@ void action_new_folder(linked_list* items, list_item* selected) {
|
||||
|
||||
if(R_SUCCEEDED(res)) {
|
||||
list_item* folderItem = NULL;
|
||||
if(R_SUCCEEDED(task_create_file_item(&folderItem, parentDir->archive, path))) {
|
||||
if(R_SUCCEEDED(task_create_file_item(&folderItem, parentDir->archive, path, FS_ATTRIBUTE_DIRECTORY))) {
|
||||
linked_list_add(items, folderItem);
|
||||
linked_list_sort(items, util_compare_file_infos);
|
||||
}
|
||||
|
@ -67,10 +67,26 @@ static Result action_paste_files_make_dst_directory(void* data, u32 index) {
|
||||
|
||||
Result res = 0;
|
||||
|
||||
u32 attributes = ((file_info*) ((list_item*) linked_list_get(&pasteData->contents, index))->data)->attributes;
|
||||
|
||||
char dstPath[FILE_PATH_MAX];
|
||||
action_paste_files_get_dst_path(pasteData, index, dstPath);
|
||||
|
||||
if(R_SUCCEEDED(res = util_ensure_dir(pasteData->target->archive, dstPath))) {
|
||||
FS_Path* fsPath = util_make_path_utf8(dstPath);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenDirectory(&dirHandle, pasteData->target->archive, *fsPath))) {
|
||||
FSDIR_Close(dirHandle);
|
||||
} else {
|
||||
res = FSUSER_CreateDirectory(pasteData->target->archive, *fsPath, attributes);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_FBI_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res)) {
|
||||
char parentPath[FILE_PATH_MAX];
|
||||
util_get_parent_path(parentPath, dstPath, FILE_PATH_MAX);
|
||||
|
||||
@ -83,7 +99,7 @@ static Result action_paste_files_make_dst_directory(void* data, u32 index) {
|
||||
|
||||
if(strncmp(parentPath, baseDstPath, FILE_PATH_MAX) == 0) {
|
||||
list_item* dstItem = NULL;
|
||||
if(R_SUCCEEDED(res) && R_SUCCEEDED(task_create_file_item(&dstItem, pasteData->target->archive, dstPath))) {
|
||||
if(R_SUCCEEDED(res) && R_SUCCEEDED(task_create_file_item(&dstItem, pasteData->target->archive, dstPath, attributes))) {
|
||||
linked_list_add(pasteData->items, dstItem);
|
||||
}
|
||||
}
|
||||
@ -136,7 +152,7 @@ static Result action_paste_files_open_dst(void* data, u32 index, void* initialRe
|
||||
if(pasteData->currExists) {
|
||||
FSFILE_Close(currHandle);
|
||||
} else {
|
||||
res = FSUSER_CreateFile(pasteData->target->archive, *fsPath, 0, size);
|
||||
res = FSUSER_CreateFile(pasteData->target->archive, *fsPath, ((file_info*) ((list_item*) linked_list_get(&pasteData->contents, index))->data)->attributes & ~FS_ATTRIBUTE_READ_ONLY, size);
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res)) {
|
||||
@ -172,7 +188,7 @@ static Result action_paste_files_close_dst(void* data, u32 index, bool succeeded
|
||||
|
||||
if(strncmp(parentPath, baseDstPath, FILE_PATH_MAX) == 0) {
|
||||
list_item* dstItem = NULL;
|
||||
if(R_SUCCEEDED(task_create_file_item(&dstItem, pasteData->target->archive, dstPath))) {
|
||||
if(R_SUCCEEDED(task_create_file_item(&dstItem, pasteData->target->archive, dstPath, ((file_info*) ((list_item*) linked_list_get(&pasteData->contents, index))->data)->attributes & ~FS_ATTRIBUTE_READ_ONLY))) {
|
||||
linked_list_add(pasteData->items, dstItem);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#define MAX_FILES 1024
|
||||
|
||||
static Result task_create_file_item_attributes(list_item** out, FS_Archive archive, const char* path, u32 attributes) {
|
||||
Result task_create_file_item(list_item** out, FS_Archive archive, const char* path, u32 attributes) {
|
||||
Result res = 0;
|
||||
|
||||
list_item* item = (list_item*) calloc(1, sizeof(list_item));
|
||||
@ -29,7 +29,7 @@ static Result task_create_file_item_attributes(list_item** out, FS_Archive archi
|
||||
fileInfo->isCia = false;
|
||||
fileInfo->isTicket = false;
|
||||
|
||||
if(util_is_dir(archive, path)) {
|
||||
if((attributes != UINT32_MAX && (attributes & FS_ATTRIBUTE_DIRECTORY)) || util_is_dir(archive, path)) {
|
||||
item->color = COLOR_DIRECTORY;
|
||||
|
||||
size_t len = strlen(path);
|
||||
@ -131,10 +131,6 @@ static Result task_create_file_item_attributes(list_item** out, FS_Archive archi
|
||||
return res;
|
||||
}
|
||||
|
||||
Result task_create_file_item(list_item** out, FS_Archive archive, const char* path) {
|
||||
return task_create_file_item_attributes(out, archive, path, UINT32_MAX);
|
||||
}
|
||||
|
||||
static int task_populate_files_compare_directory_entries(const void* e1, const void* e2) {
|
||||
FS_DirectoryEntry* ent1 = (FS_DirectoryEntry*) e1;
|
||||
FS_DirectoryEntry* ent2 = (FS_DirectoryEntry*) e2;
|
||||
@ -160,7 +156,7 @@ static void task_populate_files_thread(void* arg) {
|
||||
Result res = 0;
|
||||
|
||||
list_item* baseItem = NULL;
|
||||
if(R_SUCCEEDED(res = task_create_file_item(&baseItem, data->archive, data->path))) {
|
||||
if(R_SUCCEEDED(res = task_create_file_item(&baseItem, data->archive, data->path, UINT32_MAX))) {
|
||||
file_info* baseInfo = (file_info*) baseItem->data;
|
||||
if(baseInfo->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
strncpy(baseItem->name, "<current directory>", LIST_ITEM_NAME_MAX);
|
||||
@ -210,7 +206,7 @@ static void task_populate_files_thread(void* arg) {
|
||||
snprintf(path, FILE_PATH_MAX, "%s%s", curr->path, name);
|
||||
|
||||
list_item* item = NULL;
|
||||
if(R_SUCCEEDED(res = task_create_file_item_attributes(&item, curr->archive, path, entries[i].attributes))) {
|
||||
if(R_SUCCEEDED(res = task_create_file_item(&item, curr->archive, path, entries[i].attributes))) {
|
||||
if(data->recursive && (((file_info*) item->data)->attributes & FS_ATTRIBUTE_DIRECTORY)) {
|
||||
linked_list_add(&queue, item);
|
||||
} else {
|
||||
|
@ -227,7 +227,7 @@ Result task_populate_ext_save_data(populate_ext_save_data_data* data);
|
||||
|
||||
void task_free_file(list_item* item);
|
||||
void task_clear_files(linked_list* items);
|
||||
Result task_create_file_item(list_item** out, FS_Archive archive, const char* path);
|
||||
Result task_create_file_item(list_item** out, FS_Archive archive, const char* path, u32 attributes);
|
||||
Result task_populate_files(populate_files_data* data);
|
||||
|
||||
void task_free_pending_title(list_item* item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user