]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/FilePaths.c
MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly
[mirror_edk2.git] / MdePkg / Library / BaseLib / FilePaths.c
index 183b3234d3302e6daab2a52c3d8c3b5c38825926..29a84ea9025cc010986a8d1522eb00cc3c564709 100644 (file)
@@ -14,9 +14,8 @@
 #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
@@ -38,7 +37,9 @@ PathRemoveLastItem(
       ; 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