]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/BasePathLib/BasePathLib.c
ShellPkg: Code refine. Add error handling code to check pointer and remove redundant...
[mirror_edk2.git] / ShellPkg / Library / BasePathLib / BasePathLib.c
index 53a2a095b52ce0f9c9ef6ed7ebec0e084211762d..301bd3b279a17e749828c026f96c75e5bfe57085 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to path manipulation functions.\r
 \r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/PathLib.h>\r
 #include <Library/BaseLib.h>\r
+#include <Protocol/SimpleTextIn.h> \r
 \r
 /**\r
   Removes the last directory or file entry in a path by changing the last\r
   L'\' to a CHAR_NULL.\r
 \r
-  @param[in,out] Path    The pointer to the path to modify.\r
+  @param[in, out] Path    The pointer to the path to modify.\r
 \r
   @retval FALSE     Nothing was found to remove.\r
   @retval TRUE      A directory or file was removed.\r
@@ -79,7 +80,7 @@ PathCleanUpDirectories(
   }\r
 \r
   //\r
-  // Fix up the / vs \\r
+  // Fix up the '/' vs '\'\r
   //\r
   for (TempString = Path ; TempString != NULL && *TempString != CHAR_NULL ; TempString++) {\r
     if (*TempString == L'/') {\r
@@ -112,10 +113,18 @@ PathCleanUpDirectories(
     CopyMem(Path+StrLen(Path), TempString, TempSize);\r
   }\r
   if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) {\r
-    *TempString = CHAR_NULL;\r
+    *(TempString + 1) = CHAR_NULL;\r
   }\r
 \r
-\r
+  while ((TempString = StrStr(Path, L"\\\\")) != NULL) {\r
+    *TempString = CHAR_NULL;\r
+    TempString  += 1;\r
+    TempSize = StrSize(TempString);\r
+    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
+  }\r
+  if ((TempString = StrStr(Path, L"\\\\")) != NULL && *(TempString + 1) == CHAR_NULL) {\r
+    *(TempString) = CHAR_NULL;\r
+  }\r
 \r
   return (Path);\r
 }\r