TianoCore EDK2 master
Loading...
Searching...
No Matches
RamDiskFileExplorer.c
Go to the documentation of this file.
1
9#include "RamDiskImpl.h"
10
24BOOLEAN
26 IN OUT EFI_STATUS *Status,
27 IN OUT VOID **Buffer,
28 IN UINTN BufferSize
29 )
30{
31 BOOLEAN TryAgain;
32
33 //
34 // If this is an initial request, buffer will be null with a new buffer size
35 //
36 if ((*Buffer == NULL) && (BufferSize != 0)) {
37 *Status = EFI_BUFFER_TOO_SMALL;
38 }
39
40 //
41 // If the status code is "buffer too small", resize the buffer
42 //
43 TryAgain = FALSE;
44 if (*Status == EFI_BUFFER_TOO_SMALL) {
45 if (*Buffer != NULL) {
46 FreePool (*Buffer);
47 }
48
49 *Buffer = AllocateZeroPool (BufferSize);
50
51 if (*Buffer != NULL) {
52 TryAgain = TRUE;
53 } else {
54 *Status = EFI_OUT_OF_RESOURCES;
55 }
56 }
57
58 //
59 // If there's an error, free the buffer
60 //
61 if (!TryAgain && EFI_ERROR (*Status) && (*Buffer != NULL)) {
62 FreePool (*Buffer);
63 *Buffer = NULL;
64 }
65
66 return TryAgain;
67}
68
81 )
82{
83 EFI_STATUS Status;
84 EFI_FILE_INFO *Buffer;
85 UINTN BufferSize;
86
87 //
88 // Initialize for GrowBuffer loop
89 //
90 Buffer = NULL;
91 BufferSize = SIZE_OF_EFI_FILE_INFO + 200;
92
93 //
94 // Call the real function
95 //
96 while (GrowBuffer (&Status, (VOID **)&Buffer, BufferSize)) {
97 Status = FHand->GetInfo (
98 FHand,
99 &gEfiFileInfoGuid,
100 &BufferSize,
101 Buffer
102 );
103 }
104
105 return Buffer;
106}
UINT64 UINTN
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define SIZE_OF_EFI_FILE_INFO
Definition: FileInfo.h:62
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
BOOLEAN GrowBuffer(IN OUT EFI_STATUS *Status, IN OUT VOID **Buffer, IN UINTN BufferSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29