aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c2
-rw-r--r--Library/UefiShellUfmCommandLib/actions.c46
-rw-r--r--Library/UefiShellUfmCommandLib/actions.h1
3 files changed, 48 insertions, 1 deletions
diff --git a/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c b/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c
index d84eb21..09298d8 100644
--- a/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c
+++ b/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c
@@ -26,7 +26,7 @@ STATIC CONST struct shortcut shortcuts[] = {
{ACTION_CMD, {SCAN_F4, 0x0}, do_nothing, L"4", L"Copy"},
{ACTION_CMD, {SCAN_F5, 0x0}, do_nothing, L"5", L"RenMov"},
{ACTION_CMD, {SCAN_F6, 0x0}, mkdir, L"6", L"Mkdir"},
- {ACTION_CMD, {SCAN_F7, 0x0}, do_nothing, L"7", L"Rm"},
+ {ACTION_CMD, {SCAN_F7, 0x0}, rm, L"7", L"Rm"},
{ACTION_CMD, {SCAN_F8, 0x0}, do_nothing, L"8", L""},
{ACTION_CMD, {SCAN_F9, 0x0}, show_filesystems, L"9", L"FSs"},
{ACTION_CMD, {SCAN_F10, 0x0}, quit, L"10", L"Quit"},
diff --git a/Library/UefiShellUfmCommandLib/actions.c b/Library/UefiShellUfmCommandLib/actions.c
index fb86874..aca0e7b 100644
--- a/Library/UefiShellUfmCommandLib/actions.c
+++ b/Library/UefiShellUfmCommandLib/actions.c
@@ -2,6 +2,7 @@
#include <Library/DebugLib.h>
#include <Library/ShellLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "dir.h"
@@ -22,6 +23,9 @@
#define RIGHT_PANEL (fm_ctx.right)
#define UPANEL ((PANEL == LEFT_PANEL) ? RIGHT_PANEL : LEFT_PANEL)
+#define FILECOUNT_LENGTH 20
+STATIC CONST CHAR16 rm_title[] = L" Delete ";
+STATIC CONST CHAR16 rm_label[] = L"Delete %u files/directories?";
STATIC CONST CHAR16 mkdir_title[] = L" Create a new directory ";
STATIC CONST CHAR16 mkdir_label[] = L"Enter directory name:";
@@ -153,6 +157,48 @@ BOOLEAN mkdir(VOID)
return TRUE;
}
+BOOLEAN rm(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(rm_label) + FILECOUNT_LENGTH + 1) * sizeof(CHAR16);
+ label = AllocatePool(size);
+ if(!label)
+ return FALSE;
+
+ UnicodeSPrint(label, size, rm_label, PANEL->marked);
+ dbox = dbox_alloc(fm_ctx.scr, rm_title, label, FALSE, L"");
+
+ 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);
+ delete_file(file);
+ }
+ 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 show_filesystems(VOID)
{
return panel_cd_to(PANEL, NULL);
diff --git a/Library/UefiShellUfmCommandLib/actions.h b/Library/UefiShellUfmCommandLib/actions.h
index 57e967c..0bb301e 100644
--- a/Library/UefiShellUfmCommandLib/actions.h
+++ b/Library/UefiShellUfmCommandLib/actions.h
@@ -25,6 +25,7 @@ BOOLEAN mark(VOID);
BOOLEAN edit(VOID);
BOOLEAN hexedit(VOID);
BOOLEAN mkdir(VOID);
+BOOLEAN rm(VOID);
BOOLEAN show_filesystems(VOID);
BOOLEAN do_nothing(VOID);
BOOLEAN quit(VOID);