If the file is not a directory remove the redundant '\' char in file name 
string returned from FileHandleGetFileName.

Cc: Jaben Carsey <jaben.car...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin....@intel.com>
Reviewed-by: Jaben Carsey <jaben.car...@intel.com>
---
 MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c 
b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index f6cbfad..0bb82be 100644
--- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -856,6 +856,14 @@ FileHandleGetFileName (
     *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);
   }
 
+  if (*FullFileName != NULL && 
+      (*FullFileName)[StrLen(*FullFileName) - 1] == L'\\' && 
+      StrLen(*FullFileName) > 1 &&
+      FileHandleIsDirectory(Handle) == EFI_NOT_FOUND
+     ) {
+    (*FullFileName)[StrLen(*FullFileName) - 1] = CHAR_NULL;
+  }
+
   if (CurrentHandle != NULL) {
     CurrentHandle->Close (CurrentHandle);
   }
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to