]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Enhance PathRemoveLastItem() to support "FS0:File.txt"
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 8 Aug 2016 06:55:10 +0000 (14:55 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 10 Aug 2016 02:17:11 +0000 (10:17 +0800)
The original implementation only looks for very last backslash
and removes the string after that.
But when the path is like "FS0:File.txt" which doesn't contain
backslash, the function cannot work well.
The patch enhances the code to look for very last backslash or
colon to support the path which doesn't contain backslash.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
MdePkg/Library/BaseLib/FilePaths.c

index c72ef726ba46aeada674b235dcfd4c765aaf81b2..c8da6bb3ea7fc87d330d15b0626f84da6a98e784 100644 (file)
@@ -17,7 +17,8 @@
 \r
 /**\r
   Removes the last directory or file entry in a path by changing the last\r
-  L'\' to a CHAR_NULL.\r
+  L'\' to a CHAR_NULL. For a path which is like L"fs0:startup.nsh",\r
+  it's converted to L"fs0:".\r
 \r
   @param[in,out] Path     A pointer to the path to modify.\r
 \r
@@ -39,7 +40,7 @@ PathRemoveLastItem(
       ; Walker != NULL && *Walker != CHAR_NULL\r
       ; Walker++\r
      ){\r
-    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {\r
+    if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) {\r
       LastSlash = Walker+1;\r
     }\r
   }\r