MdePkg: Make the FileHandleGetFileName return the file name in right format.

1. If the file is not a directory remove the redundant '\' char in file name string returned from UefiFileHandleLib.FileHandleGetFileName.
2. Update function comments.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18314 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Qiu Shumin 2015-08-26 02:25:42 +00:00 committed by shenshushi
parent 12e6c7381d
commit ad6f6f8678
2 changed files with 14 additions and 2 deletions

View File

@ -356,7 +356,9 @@ FileHandleSetSize (
/** /**
Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the 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[in] Handle Handle to the Directory or File to create path to.
@param[out] FullFileName Pointer to pointer to generated full file name. It @param[out] FullFileName Pointer to pointer to generated full file name. It

View File

@ -769,7 +769,9 @@ StrnCatGrowLeft (
/** /**
Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the 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 if Handle is NULL, return EFI_INVALID_PARAMETER
@ -856,6 +858,14 @@ FileHandleGetFileName (
*FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0); *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) { if (CurrentHandle != NULL) {
CurrentHandle->Close (CurrentHandle); CurrentHandle->Close (CurrentHandle);
} }