]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Library / DxeFileExplorerProtocol / DxeFileExplorerProtocol.c
CommitLineData
426ddd0b
ED
1/** @file\r
2 Instance of file explorer Library based on gEfiFileExplorerProtocolGuid.\r
3\r
4 Implement the file explorer library instance by wrap the interface \r
5 provided in the file explorer protocol. This protocol is defined as the internal\r
6 protocol related to this implementation, not in the public spec. So, this \r
7 library instance is only for this code base.\r
8\r
9Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
10This program and the accompanying materials\r
11are licensed and made available under the terms and conditions of the BSD License\r
12which accompanies this distribution. The full text of the license may be found at\r
13http://opensource.org/licenses/bsd-license.php\r
14\r
15THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
16WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
17\r
18**/\r
19\r
20#include <Uefi.h>\r
21#include <Base.h>\r
22#include <Protocol/FileExplorer.h>\r
23\r
24#include <Library/FileExplorerLib.h>\r
25\r
26#include <Library/BaseLib.h>\r
27#include <Library/DebugLib.h>\r
28\r
29EFI_FILE_EXPLORER_PROTOCOL *mProtocol = NULL;\r
30\r
31/**\r
32 The constructor function caches the pointer to file explorer protocol.\r
33 \r
34 The constructor function locates Print2 protocol from protocol database.\r
35 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
36\r
37 @param ImageHandle The firmware allocated handle for the EFI image.\r
38 @param SystemTable A pointer to the EFI System Table.\r
39 \r
40 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
41\r
42**/\r
43EFI_STATUS\r
44EFIAPI\r
45FileExplorerConstructor (\r
46 IN EFI_HANDLE ImageHandle,\r
47 IN EFI_SYSTEM_TABLE *SystemTable\r
48 )\r
49{\r
50 EFI_STATUS Status;\r
51\r
52 Status = SystemTable->BootServices->LocateProtocol (\r
53 &gEfiFileExplorerProtocolGuid,\r
54 NULL,\r
55 (VOID**) &mProtocol\r
56 );\r
57 ASSERT_EFI_ERROR (Status);\r
58 ASSERT (mProtocol != NULL);\r
59\r
60 return Status;\r
61}\r
62\r
63/**\r
64 Choose a file in the specified directory. \r
65\r
66 If user input NULL for the RootDirectory, will choose file in the system.\r
67\r
68 If user input *File != NULL, function will return the allocate device path\r
69 info for the choosed file, caller has to free the memory after use it.\r
70\r
71 @param RootDirectory Pointer to the root directory.\r
72 @param FileType The file type need to choose.\r
73 @param ChooseHandler Function pointer to the extra task need to do\r
74 after choose one file.\r
75 @param File Return the device path for the last time chosed file.\r
76\r
77 @retval EFI_SUCESS Choose file success.\r
78 @retval EFI_INVALID_PARAMETER Both ChooseHandler and return device path are NULL\r
79 One of them must not NULL.\r
80 @retval Other errors Choose file failed.\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84ChooseFile (\r
85 IN EFI_DEVICE_PATH_PROTOCOL *RootDirectory,\r
86 IN CHAR16 *FileType, OPTIONAL\r
87 IN CHOOSE_HANDLER ChooseHandler, OPTIONAL\r
88 OUT EFI_DEVICE_PATH_PROTOCOL **File OPTIONAL\r
89 )\r
90{\r
91 return mProtocol->ChooseFile (RootDirectory, FileType, ChooseHandler, File);\r
92}\r
93\r