aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-11-17 18:25:41 +0300
committerJoursoir <chat@joursoir.net>2021-11-17 18:25:41 +0300
commit7bbbcb62f632e12edc228b1ab675db88a331b20c (patch)
treef99309413dc3b00fe60c0d0677f083f39fdbe721 /Library
parentdc3f1f5224c86c3d99f6c401accadd2769552038 (diff)
downloadufm-7bbbcb62f632e12edc228b1ab675db88a331b20c.tar.gz
ufm-7bbbcb62f632e12edc228b1ab675db88a331b20c.tar.bz2
ufm-7bbbcb62f632e12edc228b1ab675db88a331b20c.zip
dir: make dirl_getn()
Diffstat (limited to 'Library')
-rw-r--r--Library/UefiShellUfmCommandLib/dir.c18
-rw-r--r--Library/UefiShellUfmCommandLib/dir.h10
2 files changed, 28 insertions, 0 deletions
diff --git a/Library/UefiShellUfmCommandLib/dir.c b/Library/UefiShellUfmCommandLib/dir.c
index 8e3a083..6049d18 100644
--- a/Library/UefiShellUfmCommandLib/dir.c
+++ b/Library/UefiShellUfmCommandLib/dir.c
@@ -88,3 +88,21 @@ struct dir_list *scandir(CONST CHAR16 *search_path, CONST CHAR16 *wildcard,
SHELL_FREE_NON_NULL(path);
return list;
}
+
+EFI_SHELL_FILE_INFO *dirl_getn(struct dir_list *dl, UINTN n)
+{
+ UINTN i = 1;
+ EFI_SHELL_FILE_INFO *list_head, *node;
+ list_head = dl->list_head;
+
+ if(n < 1 || n > dl->len)
+ return NULL;
+
+ node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&list_head->Link);
+ while(!IsNull(&list_head->Link, &node->Link) && i != n) {
+ node = (EFI_SHELL_FILE_INFO *)GetNextNode(&list_head->Link, &node->Link);
+ i++;
+ }
+
+ return node;
+}
diff --git a/Library/UefiShellUfmCommandLib/dir.h b/Library/UefiShellUfmCommandLib/dir.h
index 94ad601..912b00f 100644
--- a/Library/UefiShellUfmCommandLib/dir.h
+++ b/Library/UefiShellUfmCommandLib/dir.h
@@ -41,4 +41,14 @@ VOID dirl_release(struct dir_list *dl);
struct dir_list *scandir(CONST CHAR16 *search_path, CONST CHAR16 *wildcard,
CONST UINT64 attr);
+/*
+ * Gets the data stored in the specified node of directory linked list
+ *
+ * dl: the pointer to the directory list
+ * n: the node number (starts with 1)
+ *
+ * return: A pointer to the EFI_SHELL_FILE_INFO or NULL if search fails
+*/
+EFI_SHELL_FILE_INFO *dirl_getn(struct dir_list *dl, UINTN n);
+
#endif /* UFM_DIR_H */