]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c
MdeModulePkg: Change OPTIONAL keyword usage style
[mirror_edk2.git] / MdeModulePkg / Library / DxeFileExplorerProtocol / DxeFileExplorerProtocol.c
1 /** @file
2 Instance of file explorer Library based on gEfiFileExplorerProtocolGuid.
3
4 Implement the file explorer library instance by wrap the interface
5 provided in the file explorer protocol. This protocol is defined as the internal
6 protocol related to this implementation, not in the public spec. So, this
7 library instance is only for this code base.
8
9 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
10 SPDX-License-Identifier: BSD-2-Clause-Patent
11
12 **/
13
14 #include <Uefi.h>
15 #include <Base.h>
16 #include <Protocol/FileExplorer.h>
17
18 #include <Library/FileExplorerLib.h>
19
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
22
23 EFI_FILE_EXPLORER_PROTOCOL *mProtocol = NULL;
24
25 /**
26 The constructor function caches the pointer to file explorer protocol.
27
28 The constructor function locates Print2 protocol from protocol database.
29 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
30
31 @param ImageHandle The firmware allocated handle for the EFI image.
32 @param SystemTable A pointer to the EFI System Table.
33
34 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
35
36 **/
37 EFI_STATUS
38 EFIAPI
39 FileExplorerConstructor (
40 IN EFI_HANDLE ImageHandle,
41 IN EFI_SYSTEM_TABLE *SystemTable
42 )
43 {
44 EFI_STATUS Status;
45
46 Status = SystemTable->BootServices->LocateProtocol (
47 &gEfiFileExplorerProtocolGuid,
48 NULL,
49 (VOID**) &mProtocol
50 );
51 ASSERT_EFI_ERROR (Status);
52 ASSERT (mProtocol != NULL);
53
54 return Status;
55 }
56
57 /**
58 Choose a file in the specified directory.
59
60 If user input NULL for the RootDirectory, will choose file in the system.
61
62 If user input *File != NULL, function will return the allocate device path
63 info for the choosed file, caller has to free the memory after use it.
64
65 @param RootDirectory Pointer to the root directory.
66 @param FileType The file type need to choose.
67 @param ChooseHandler Function pointer to the extra task need to do
68 after choose one file.
69 @param File Return the device path for the last time chosed file.
70
71 @retval EFI_SUCESS Choose file success.
72 @retval EFI_INVALID_PARAMETER Both ChooseHandler and return device path are NULL
73 One of them must not NULL.
74 @retval Other errors Choose file failed.
75 **/
76 EFI_STATUS
77 EFIAPI
78 ChooseFile (
79 IN EFI_DEVICE_PATH_PROTOCOL *RootDirectory,
80 IN CHAR16 *FileType OPTIONAL,
81 IN CHOOSE_HANDLER ChooseHandler OPTIONAL,
82 OUT EFI_DEVICE_PATH_PROTOCOL **File OPTIONAL
83 )
84 {
85 return mProtocol->ChooseFile (RootDirectory, FileType, ChooseHandler, File);
86 }