https://bugzilla.tianocore.org/show_bug.cgi?id=239
When the input path for API PathRemoveLastItem() is a root path like
'fs0:\', the API will return TRUE (indicating a directory or file was
removed from the path) and modifies the path to 'fs0:'. In fact, there's
no directory or file removed in the above case.
This commit adds additional check to resolve this issue and modifies the
API's description to make it more straightforward.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
- Removes the last directory or file entry in a path by changing the last\r
- L'\' to a CHAR_NULL.\r
+ Removes the last directory or file entry in a path.\r
\r
@param[in, out] Path The pointer to the path to modify.\r
\r
\r
@param[in, out] Path The pointer to the path to modify.\r
\r
#include <Library/BaseLib.h>\r
\r
/**\r
#include <Library/BaseLib.h>\r
\r
/**\r
- Removes the last directory or file entry in a path by changing the last\r
- L'\' to a CHAR_NULL. For a path which is like L"fs0:startup.nsh",\r
- it's converted to L"fs0:".\r
+ Removes the last directory or file entry in a path. For a path which is\r
+ like L"fs0:startup.nsh", it's converted to L"fs0:".\r
\r
@param[in,out] Path A pointer to the path to modify.\r
\r
\r
@param[in,out] Path A pointer to the path to modify.\r
\r
; Walker != NULL && *Walker != CHAR_NULL\r
; Walker++\r
){\r
; Walker != NULL && *Walker != CHAR_NULL\r
; Walker++\r
){\r
- if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) {\r
+ if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {\r
+ LastSlash = Walker+1;\r
+ } else if (*Walker == L':' && *(Walker + 1) != L'\\' && *(Walker + 1) != CHAR_NULL) {\r
LastSlash = Walker+1;\r
}\r
}\r
LastSlash = Walker+1;\r
}\r
}\r