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