From 54b1e0ec814d8a8ac0aea2262ba04d7567545197 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Mon, 8 Aug 2016 14:55:10 +0800 Subject: MdePkg: Enhance PathRemoveLastItem() to support "FS0:File.txt" 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 Reviewed-by: Jaben Carsey Reviewed-by: Tapan Shah --- MdePkg/Library/BaseLib/FilePaths.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'MdePkg/Library') diff --git a/MdePkg/Library/BaseLib/FilePaths.c b/MdePkg/Library/BaseLib/FilePaths.c index c72ef726ba..c8da6bb3ea 100644 --- a/MdePkg/Library/BaseLib/FilePaths.c +++ b/MdePkg/Library/BaseLib/FilePaths.c @@ -17,7 +17,8 @@ /** Removes the last directory or file entry in a path by changing the last - L'\' to a CHAR_NULL. + L'\' to a CHAR_NULL. For a path which is like L"fs0:startup.nsh", + it's converted to L"fs0:". @param[in,out] Path A pointer to the path to modify. @@ -39,7 +40,7 @@ PathRemoveLastItem( ; Walker != NULL && *Walker != CHAR_NULL ; Walker++ ){ - if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) { + if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) { LastSlash = Walker+1; } } -- cgit v1.2.3