]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Make the FileHandleGetFileName return the file name in right format.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 26 Aug 2015 02:25:42 +0000 (02:25 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 26 Aug 2015 02:25:42 +0000 (02:25 +0000)
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

MdePkg/Include/Library/FileHandleLib.h
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c

index fdbdc3ade476f33485580e44dad673aeb17b80ac..00706f964dfd723d4d9a99157bc36e04476083d2 100644 (file)
@@ -356,7 +356,9 @@ FileHandleSetSize (
 \r
 /**\r
   Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
-  directory 'stack'.\r
+  directory 'stack'. If the file is a directory, then append the '\' char at the \r
+  end of name string. If it's not a directory, then the last '\' should not be \r
+  added.\r
 \r
   @param[in] Handle             Handle to the Directory or File to create path to.\r
   @param[out] FullFileName      Pointer to pointer to generated full file name.  It\r
index a31d12b862d760cad6bd44f3e96c36dbb134e344..04a2f189eceb0c650c3d632a2949898338c3e5ae 100644 (file)
@@ -769,7 +769,9 @@ StrnCatGrowLeft (
 \r
 /**\r
   Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
-  directory 'stack'.\r
+  directory 'stack'. If the file is a directory, then append the '\' char at the \r
+  end of name string. If it's not a directory, then the last '\' should not be \r
+  added.\r
 \r
   if Handle is NULL, return EFI_INVALID_PARAMETER\r
 \r
@@ -856,6 +858,14 @@ FileHandleGetFileName (
     *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
   }\r
 \r
+  if (*FullFileName != NULL && \r
+      (*FullFileName)[StrLen(*FullFileName) - 1] == L'\\' && \r
+      StrLen(*FullFileName) > 1 &&\r
+      FileHandleIsDirectory(Handle) == EFI_NOT_FOUND\r
+     ) {\r
+    (*FullFileName)[StrLen(*FullFileName) - 1] = CHAR_NULL;\r
+  }\r
+\r
   if (CurrentHandle != NULL) {\r
     CurrentHandle->Close (CurrentHandle);\r
   }\r