From dcb8f1393ef299df31044593a2f1a178b18d7f4f Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 30 Nov 2021 17:52:13 +0300 Subject: panel: make panel_cd_to() --- Library/UefiShellUfmCommandLib/panel.c | 32 ++++++++++++++++++++++++++++++++ Library/UefiShellUfmCommandLib/panel.h | 10 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/Library/UefiShellUfmCommandLib/panel.c b/Library/UefiShellUfmCommandLib/panel.c index c8d3565..c76fb55 100644 --- a/Library/UefiShellUfmCommandLib/panel.c +++ b/Library/UefiShellUfmCommandLib/panel.c @@ -305,3 +305,35 @@ BOOLEAN panel_move_cursor(struct panel_ctx *p, UINTN line) return TRUE; } +BOOLEAN panel_cd_to(struct panel_ctx *p, CONST CHAR16 *path) +{ + struct fs_array *fsa = NULL; + struct dir_list *dirs = NULL; + ASSERT(p != NULL); + + if(path) { + dirs = scandir(path, L"*", 0); + if(!dirs) + return FALSE; + } + else { + fsa = scanfs(); + if(!fsa) + return FALSE; + } + + set_cwd(p, path); + if(p->dirs) + dirl_release(p->dirs); + if(p->fsa) + fsa_release(p->fsa); + p->dirs = dirs; + p->fsa = fsa; + p->marked = 0; + p->start_entry = 0; + + update_marked_info(p); + panel_move_cursor(p, 1); + return TRUE; +} + diff --git a/Library/UefiShellUfmCommandLib/panel.h b/Library/UefiShellUfmCommandLib/panel.h index 1d71258..908d260 100644 --- a/Library/UefiShellUfmCommandLib/panel.h +++ b/Library/UefiShellUfmCommandLib/panel.h @@ -60,4 +60,14 @@ VOID panel_release(struct panel_ctx *p); */ BOOLEAN panel_move_cursor(struct panel_ctx *p, UINTN line); +/* + * Changes the working directory + * + * p: the panel on which to operate + * path: the pointer to path string + * + * return: FALSE upon failure and TRUE upon successful completion +*/ +BOOLEAN panel_cd_to(struct panel_ctx *p, CONST CHAR16 *path); + #endif /* UFM_PANEL_H */ -- cgit v1.2.3-18-g5258