From 7e1a69e43832a7ada128e3f47c9d71071e1336c1 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 14 Dec 2021 13:39:09 +0300 Subject: actions: make frontend copying file --- .../UefiShellUfmCommandLib.c | 2 +- Library/UefiShellUfmCommandLib/actions.c | 44 ++++++++++++++++++++++ Library/UefiShellUfmCommandLib/actions.h | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c b/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c index 1920b13..f7bc2fb 100644 --- a/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c +++ b/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c @@ -23,7 +23,7 @@ STATIC CONST struct shortcut shortcuts[] = { {ACTION_CMD, {SCAN_F1, 0x0}, do_nothing, L"1", L"Help"}, {ACTION_CMD, {SCAN_F2, 0x0}, edit, L"2", L"Edit"}, {ACTION_CMD, {SCAN_F3, 0x0}, hexedit, L"3", L"Hex"}, - {ACTION_CMD, {SCAN_F4, 0x0}, do_nothing, L"4", L"Copy"}, + {ACTION_CMD, {SCAN_F4, 0x0}, cp, L"4", L"Copy"}, {ACTION_CMD, {SCAN_F5, 0x0}, mv, L"5", L"RenMov"}, {ACTION_CMD, {SCAN_F6, 0x0}, mkdir, L"6", L"Mkdir"}, {ACTION_CMD, {SCAN_F7, 0x0}, rm, L"7", L"Rm"}, diff --git a/Library/UefiShellUfmCommandLib/actions.c b/Library/UefiShellUfmCommandLib/actions.c index 596e7c4..0089952 100644 --- a/Library/UefiShellUfmCommandLib/actions.c +++ b/Library/UefiShellUfmCommandLib/actions.c @@ -24,6 +24,8 @@ #define UPANEL ((PANEL == LEFT_PANEL) ? RIGHT_PANEL : LEFT_PANEL) #define FILECOUNT_LENGTH 20 +STATIC CONST CHAR16 cp_title[] = L" Copy "; +STATIC CONST CHAR16 cp_label[] = L"Copy %u files/directories to:"; STATIC CONST CHAR16 mv_title[] = L" Move "; STATIC CONST CHAR16 mv_label[] = L"Move %u files/directories to:"; STATIC CONST CHAR16 rm_title[] = L" Delete "; @@ -130,6 +132,48 @@ BOOLEAN hexedit(VOID) return TRUE; } +BOOLEAN cp(VOID) +{ + struct dbox_ctx *dbox; + UINTN i, size, line = PANEL->curline; + CHAR16 *label; + EFI_SHELL_FILE_INFO *file; + BOOLEAN status_op; + + if(!PANEL->cwd) + return FALSE; + + if(PANEL->marked < 1) + return FALSE; + + size = (StrLen(cp_label) + FILECOUNT_LENGTH + 1) * sizeof(CHAR16); + label = AllocatePool(size); + if(!label) + return FALSE; + + UnicodeSPrint(label, size, cp_label, PANEL->marked); + dbox = dbox_alloc(fm_ctx.scr, cp_title, label, TRUE, UPANEL->cwd); + + dbox_refresh(dbox); + status_op = dbox_handle(dbox); + if(status_op) { + for(i = 1; i <= PANEL->dirs->len; i++) { + if(PANEL->dirs->marked[i-1] == FALSE) + continue; + + file = dirl_getn(PANEL->dirs, i); + copy_file(file->FullName, dbox->in->buffer); // NOT UPANEL->cwd!!! + } + panel_cd_to(PANEL, PANEL->cwd); + panel_move_cursor(PANEL, (line > PANEL->dirs->len) ? PANEL->dirs->len : line); + } + + redraw(); + FreePool(label); + dbox_release(dbox); + return TRUE; +} + BOOLEAN mv(VOID) { struct dbox_ctx *dbox; diff --git a/Library/UefiShellUfmCommandLib/actions.h b/Library/UefiShellUfmCommandLib/actions.h index 1080678..d6896bd 100644 --- a/Library/UefiShellUfmCommandLib/actions.h +++ b/Library/UefiShellUfmCommandLib/actions.h @@ -24,6 +24,7 @@ BOOLEAN execute(VOID); BOOLEAN mark(VOID); BOOLEAN edit(VOID); BOOLEAN hexedit(VOID); +BOOLEAN cp(VOID); BOOLEAN mv(VOID); BOOLEAN mkdir(VOID); BOOLEAN rm(VOID); -- cgit v1.2.3-18-g5258