1. If the file is not a directory remove the redundant '\' char in file name string returned from FileHandleGetFileName. 2. Update function comments.
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/Include/Library/FileHandleLib.h | 4 +++- MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Library/FileHandleLib.h b/MdePkg/Include/Library/FileHandleLib.h index fdbdc3a..00706f9 100644 --- a/MdePkg/Include/Library/FileHandleLib.h +++ b/MdePkg/Include/Library/FileHandleLib.h @@ -356,7 +356,9 @@ FileHandleSetSize ( /** Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the - directory 'stack'. + directory 'stack'. If the file is a directory, then append the '\' char at the + end of name string. If it's not a directory, then the last '\' should not be + added. @param[in] Handle Handle to the Directory or File to create path to. @param[out] FullFileName Pointer to pointer to generated full file name. It diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c index a31d12b..04a2f18 100644 --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c @@ -769,7 +769,9 @@ StrnCatGrowLeft ( /** Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the - directory 'stack'. + directory 'stack'. If the file is a directory, then append the '\' char at the + end of name string. If it's not a directory, then the last '\' should not be + added. if Handle is NULL, return EFI_INVALID_PARAMETER @@ -856,6 +858,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