]> git.proxmox.com Git - mirror_edk2.git/commitdiff
This refactors 3 functions out of ShellCommandLib and puts them into a new library...
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 30 Jun 2011 22:58:53 +0000 (22:58 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 30 Jun 2011 22:58:53 +0000 (22:58 +0000)
1) Remove the 3 functions out of the shell's internal library (ShellCommandLib)
2) Add a new library class (PathLib)
3) Add an instance of this class (BasePathLib)
4) Change all internal shell callers to use this new library class.

signed-off-by: jcarsey
reviewed-by: jljusten

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11936 6f19259b-4bc3-4df7-8a09-765794883524

21 files changed:
ShellPkg/Application/Shell/FileHandleWrappers.c
ShellPkg/Application/Shell/Shell.c
ShellPkg/Application/Shell/Shell.h
ShellPkg/Application/Shell/Shell.inf
ShellPkg/Application/Shell/ShellProtocol.c
ShellPkg/Include/Library/PathLib.h [new file with mode: 0644]
ShellPkg/Include/Library/ShellCommandLib.h
ShellPkg/Library/BasePathLib/BasePathLib.c [new file with mode: 0644]
ShellPkg/Library/BasePathLib/BasePathLib.inf [new file with mode: 0644]
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
ShellPkg/ShellPkg.dec
ShellPkg/ShellPkg.dsc

index 3cadc41e0b390771c5f4ad91d10c85b93cb29e39..22e8c71d12b25162a9b2f2e0f6e0279659bbaa69 100644 (file)
@@ -522,7 +522,7 @@ FileInterfaceStdInRead(
         }\r
         StrCat(TabStr, L"*");\r
         FoundFileList = NULL;\r
-//        TabStr = CleanPath(TabStr);\r
+//        TabStr = PathCleanUpDirectories(TabStr);\r
         Status  = ShellInfoObject.NewEfiShellProtocol->FindFiles(TabStr, &FoundFileList);\r
         for ( TempStr = CurrentString\r
             ; *TempStr == L' '\r
index ae4c0606e343de4a4768090e662c8842282be079..452c65588be502a140615260cd71e94d334521bd 100644 (file)
@@ -859,7 +859,7 @@ DoStartupScript(
       *TempSpot = CHAR_NULL;\r
     }\r
     FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, ((FILEPATH_DEVICE_PATH*)FilePath)->PathName, 0);\r
-    ChopLastSlash(FileStringPath);\r
+    PathRemoveLastItem(FileStringPath);\r
     FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, mStartupScript, 0);\r
     Status = ShellInfoObject.NewEfiShellProtocol->OpenFileByName(FileStringPath, &FileHandle, EFI_FILE_MODE_READ);\r
     FreePool(FileStringPath);\r
index 51ec4f3a4bd275699d9e0afd55767202cfbccd82..e79c5481f376ae306e550952a47df5b56d82d068 100644 (file)
@@ -44,6 +44,7 @@
 #include <Library/HiiLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/HandleParsingLib.h>\r
+#include <Library/PathLib.h>\r
 \r
 #include "ShellParametersProtocol.h"\r
 #include "ShellProtocol.h"\r
index f873fdaf6cbdb506390c250f66c6d4bd7b29d882..756e84137e31b24ddfe40e3527ecfcc3ebb46af9 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 #  This is the shell application\r
 #\r
-#  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -69,6 +69,7 @@
   HiiLib\r
   SortLib\r
   HandleParsingLib\r
+  PathLib\r
 \r
 [Guids]\r
   gShellVariableGuid                                      # ALWAYS_CONSUMED\r
index f0416ca93705c38f8b12baa4743048f1c1c33055..e42f081834de528d600b67725854bd1716fb2299 100644 (file)
@@ -529,7 +529,7 @@ EfiShellGetDevicePathFromFilePath(
     StrCpy(NewPath, Cwd);\r
     if (*Path == L'\\') {\r
       Path++;\r
-      while (ChopLastSlash(NewPath)) ;\r
+      while (PathRemoveLastItem(NewPath)) ;\r
     }\r
     StrCat(NewPath, Path);\r
     DevicePathForReturn = EfiShellGetDevicePathFromFilePath(NewPath);\r
@@ -2232,7 +2232,7 @@ EfiShellFindFiles(
   }\r
   StrCpy(PatternCopy, FilePattern);\r
 \r
-  PatternCopy = CleanPath(PatternCopy);\r
+  PatternCopy = PathCleanUpDirectories(PatternCopy);\r
 \r
   Count = StrStr(PatternCopy, L":") - PatternCopy;\r
   Count += 2;\r
@@ -2293,7 +2293,7 @@ EfiShellOpenFileList(
   CONST CHAR16        *CurDir;\r
   BOOLEAN             Found;\r
 \r
-  ShellCommandCleanPath(Path);\r
+  PathCleanUpDirectories(Path);\r
 \r
   Path2Size     = 0;\r
   Path2         = NULL;\r
@@ -2315,7 +2315,7 @@ EfiShellOpenFileList(
     StrnCatGrow(&Path2, &Path2Size, CurDir, 0);\r
     if (*Path == L'\\') {\r
       Path++;\r
-      while (ChopLastSlash(Path2)) ;\r
+      while (PathRemoveLastItem(Path2)) ;\r
     }\r
     ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));\r
     StrnCatGrow(&Path2, &Path2Size, Path, 0);\r
@@ -2324,7 +2324,7 @@ EfiShellOpenFileList(
     StrnCatGrow(&Path2, NULL, Path, 0);\r
   }\r
 \r
-  CleanPath (Path2);\r
+  PathCleanUpDirectories (Path2);\r
 \r
   //\r
   // do the search\r
@@ -2677,7 +2677,7 @@ EfiShellSetCurDir(
   DirectoryName = StrnCatGrow(&DirectoryName, NULL, Dir, 0);\r
   ASSERT(DirectoryName != NULL);\r
 \r
-  CleanPath(DirectoryName);\r
+  PathCleanUpDirectories(DirectoryName);\r
 \r
   if (FileSystem == NULL) {\r
     //\r
diff --git a/ShellPkg/Include/Library/PathLib.h b/ShellPkg/Include/Library/PathLib.h
new file mode 100644 (file)
index 0000000..912b1f1
--- /dev/null
@@ -0,0 +1,56 @@
+/** @file\r
+  Provides interface to path manipulation functions.\r
+\r
+  Copyright (c) 2011, 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
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef _PATH_LIB_\r
+#define _PATH_LIB_\r
+\r
+#include <Base.h>\r
+#include <Library/BaseMemoryLib.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
+\r
+  @retval FALSE     Nothing was found to remove.\r
+  @retval TRUE      A directory or file was removed.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PathRemoveLastItem(\r
+  IN OUT CHAR16 *Path\r
+  );\r
+\r
+/**\r
+  Function to clean up paths.  \r
+  \r
+  - Single periods in the path are removed.\r
+  - Double periods in the path are removed along with a single parent directory.\r
+  - Forward slashes L'/' are converted to backward slashes L'\'.\r
+\r
+  This will be done inline and the existing buffer may be larger than required \r
+  upon completion.\r
+\r
+  @param[in] Path       The pointer to the string containing the path.\r
+\r
+  @retval NULL          An error occured.\r
+  @return Path in all other instances.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PathCleanUpDirectories(\r
+  IN CHAR16 *Path\r
+  );\r
+\r
+#endif //_PATH_LIB_\r
index 027c0caad50e1bd9d53c0fb2f7e22d701105e90d..e998ac51b9777fc705385645a8ddf7135aad360f 100644 (file)
@@ -572,20 +572,6 @@ ShellCommandCreateInitialMappingsAndPaths(
   VOID\r
   );\r
 \r
-/**\r
-  Function to standardize the directory indicators to \ characters.\r
-\r
-  @param[in,out] Path   The pointer to the path string to fix.\r
-\r
-  @retval NULL          The operation failed.\r
-  @return               The Path pointer.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-ShellCommandCleanPath (\r
-  IN OUT CHAR16 *Path\r
-  );\r
-\r
 /**\r
   Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
 \r
@@ -734,35 +720,4 @@ FreeBufferList (
   IN BUFFER_LIST *List\r
   );\r
 \r
-/**\r
-  Chops off last directory or file entry in a path by changing the last '\' to a CHAR_NULL\r
-\r
-  @param[in,out] PathToReturn   The pointer to the path to modify.\r
-\r
-  @retval FALSE     No directory was found to chop off.\r
-  @retval TRUE      A directory was chopped off.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ChopLastSlash(\r
-  IN OUT CHAR16 *PathToReturn\r
-  );\r
-\r
-/**\r
-  Function to clean up paths.  Removes the following items:\r
-    single periods in the path (no need for the current directory tag)\r
-    double periods in the path and removes a single parent directory.\r
-\r
-  This will be done inline and the resultant string may be be 'too big'.\r
-\r
-  @param[in] PathToReturn  The pointer to the string containing the path.\r
-\r
-  @return PathToReturn is always returned.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-CleanPath(\r
-  IN CHAR16 *PathToReturn\r
-  );\r
-\r
 #endif //_SHELL_COMMAND_LIB_\r
diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.c b/ShellPkg/Library/BasePathLib/BasePathLib.c
new file mode 100644 (file)
index 0000000..53a2a09
--- /dev/null
@@ -0,0 +1,122 @@
+/** @file\r
+  Provides interface to path manipulation functions.\r
+\r
+  Copyright (c) 2011, 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
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Base.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PathLib.h>\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.\r
+\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
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PathRemoveLastItem(\r
+  IN OUT CHAR16 *Path\r
+  )\r
+{\r
+  CHAR16        *Walker;\r
+  CHAR16        *LastSlash;\r
+  //\r
+  // get directory name from path... ('chop' off extra)\r
+  //\r
+  for ( Walker = Path, LastSlash = NULL\r
+      ; Walker != NULL && *Walker != CHAR_NULL\r
+      ; Walker++\r
+     ){\r
+    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {\r
+      LastSlash = Walker+1;\r
+    }\r
+  }\r
+  if (LastSlash != NULL) {\r
+    *LastSlash = CHAR_NULL;\r
+    return (TRUE);\r
+  }\r
+  return (FALSE);\r
+}\r
+\r
+/**\r
+  Function to clean up paths.  \r
+  \r
+  - Single periods in the path are removed.\r
+  - Double periods in the path are removed along with a single parent directory.\r
+  - Forward slashes L'/' are converted to backward slashes L'\'.\r
+\r
+  This will be done inline and the existing buffer may be larger than required \r
+  upon completion.\r
+\r
+  @param[in] Path       The pointer to the string containing the path.\r
+\r
+  @retval NULL          An error occured.\r
+  @return Path in all other instances.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PathCleanUpDirectories(\r
+  IN CHAR16 *Path\r
+  )\r
+{\r
+  CHAR16  *TempString;\r
+  UINTN   TempSize;\r
+  if (Path==NULL) {\r
+    return(NULL);\r
+  }\r
+\r
+  //\r
+  // Fix up the / vs \\r
+  //\r
+  for (TempString = Path ; TempString != NULL && *TempString != CHAR_NULL ; TempString++) {\r
+    if (*TempString == L'/') {\r
+      *TempString = L'\\';\r
+    }\r
+  }\r
+\r
+  //\r
+  // Fix up the ..\r
+  //\r
+  while ((TempString = StrStr(Path, L"\\..\\")) != NULL) {\r
+    *TempString = CHAR_NULL;\r
+    TempString  += 4;\r
+    PathRemoveLastItem(Path);\r
+    TempSize = StrSize(TempString);\r
+    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
+  }\r
+  if ((TempString = StrStr(Path, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) {\r
+    *TempString = CHAR_NULL;\r
+    PathRemoveLastItem(Path);\r
+  }\r
+\r
+  //\r
+  // Fix up the .\r
+  //\r
+  while ((TempString = StrStr(Path, L"\\.\\")) != NULL) {\r
+    *TempString = CHAR_NULL;\r
+    TempString  += 2;\r
+    TempSize = StrSize(TempString);\r
+    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
+  }\r
+  if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) {\r
+    *TempString = CHAR_NULL;\r
+  }\r
+\r
+\r
+\r
+  return (Path);\r
+}\r
+\r
diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.inf b/ShellPkg/Library/BasePathLib/BasePathLib.inf
new file mode 100644 (file)
index 0000000..a9bd6a8
--- /dev/null
@@ -0,0 +1,38 @@
+##  @file\r
+#  Provides interface to path manipulation functions.\r
+#\r
+#  Copyright (c) 2011, Intel Corporation. All rights reserved. <BR>\r
+#\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
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010006\r
+  BASE_NAME                      = BasePathLib\r
+  FILE_GUID                      = ED244F93-B97A-4a17-83E0-A03CF2A7F7B4\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PathLib|UEFI_APPLICATION UEFI_DRIVER\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  BasePathLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  \r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  BaseLib
\ No newline at end of file
index 82a9e78ed58024bf00bfe4e03ab003af5ad24b09..28b7dda51e8b1a6560c300340469a5ab390ca335 100644 (file)
@@ -1122,30 +1122,6 @@ ShellCommandCreateInitialMappingsAndPaths(
   return (EFI_SUCCESS);\r
 }\r
 \r
-/**\r
-  Function to make sure all directory delimeters are backslashes.\r
-\r
-  @param[in,out] Path     The path to modify.\r
-\r
-  @return Path.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-ShellCommandCleanPath (\r
-  IN OUT CHAR16 *Path\r
-  )\r
-{\r
-  CHAR16  *Path2;\r
-\r
-  for (Path2 = Path ; Path2 != NULL && *Path2 != CHAR_NULL ; Path2++) {\r
-    if (*Path2 == L'/') {\r
-      *Path2 = L'\\';\r
-    }\r
-  }\r
-\r
-  return (Path);\r
-}\r
-\r
 /**\r
   Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
 \r
@@ -1489,85 +1465,3 @@ FreeBufferList (
   }\r
 }\r
 \r
-/**\r
-  Chops off last directory or file entry in a path leaving the trailing slash\r
-\r
-  @param[in,out] PathToReturn The path to modify.\r
-\r
-  @retval FALSE     No directory was found to chop off.\r
-  @retval TRUE      A directory was chopped off.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ChopLastSlash(\r
-  IN OUT CHAR16 *PathToReturn\r
-  )\r
-{\r
-  CHAR16        *Walker;\r
-  CHAR16        *LastSlash;\r
-  //\r
-  // get directory name from path... ('chop' off extra)\r
-  //\r
-  for ( Walker = PathToReturn, LastSlash = NULL\r
-      ; Walker != NULL && *Walker != CHAR_NULL\r
-      ; Walker++\r
-     ){\r
-    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {\r
-      LastSlash = Walker+1;\r
-    }\r
-  }\r
-  if (LastSlash != NULL) {\r
-    *LastSlash = CHAR_NULL;\r
-    return (TRUE);\r
-  }\r
-  return (FALSE);\r
-}\r
-\r
-/**\r
-  Function to clean up paths.  Removes the following items:\r
-    single periods in the path (no need for the current directory tag)\r
-    double periods in the path and removes a single parent directory.\r
-\r
-  This will be done inline and the resultant string may be be 'too big'.\r
-\r
-  @param[in] PathToReturn  The pointer to the string containing the path.\r
-\r
-  @return PathToReturn is always returned.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-CleanPath(\r
-  IN CHAR16 *PathToReturn\r
-  )\r
-{\r
-  CHAR16  *TempString;\r
-  UINTN   TempSize;\r
-  if (PathToReturn==NULL) {\r
-    return(NULL);\r
-  }\r
-  //\r
-  // Fix up the directory name\r
-  //\r
-  while ((TempString = StrStr(PathToReturn, L"\\..\\")) != NULL) {\r
-    *TempString = CHAR_NULL;\r
-    TempString  += 4;\r
-    ChopLastSlash(PathToReturn);\r
-    TempSize = StrSize(TempString);\r
-    CopyMem(PathToReturn+StrLen(PathToReturn), TempString, TempSize);\r
-  }\r
-  if ((TempString = StrStr(PathToReturn, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) {\r
-    *TempString = CHAR_NULL;\r
-    ChopLastSlash(PathToReturn);\r
-  }\r
-  while ((TempString = StrStr(PathToReturn, L"\\.\\")) != NULL) {\r
-    *TempString = CHAR_NULL;\r
-    TempString  += 2;\r
-    TempSize = StrSize(TempString);\r
-    CopyMem(PathToReturn+StrLen(PathToReturn), TempString, TempSize);\r
-  }\r
-  if ((TempString = StrStr(PathToReturn, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) {\r
-    *TempString = CHAR_NULL;\r
-  }\r
-  return (PathToReturn);\r
-}\r
-\r
index 62c713e58973b473cd2465bdb5cdf5519d40ca43..b7f423ff4dc6b248ffe7dc74d644561a5ebbf613 100644 (file)
@@ -14,6 +14,7 @@
 \r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
+#include <Library/PathLib.h>\r
 \r
 typedef enum {\r
   EndTagOr,\r
@@ -95,10 +96,7 @@ IsValidProfile (
   CONST CHAR16  *TempLocation;\r
 \r
   ProfilesString = ShellGetEnvironmentVariable(L"profiles");\r
-  //\r
-  // According to the Shell spec this is a required environment variable.\r
-  //\r
-  ASSERT(ProfileString != NULL);\r
+  ASSERT(ProfilesString != NULL);\r
   TempLocation = StrStr(ProfilesString, String);\r
   if ((TempLocation != NULL) && (*(TempLocation-1) == L';') && (*(TempLocation+StrLen(String)) == L';')) {\r
     return (TRUE);\r
index 8b04b7d369eff111529763084f0c3574cd01de35..3a62cc3c8e3e3db5c3e66df486ba70a06ae6fc22 100644 (file)
@@ -50,6 +50,7 @@
   UefiBootServicesTableLib\r
   SortLib\r
   PrintLib\r
+  PathLib\r
 \r
 [Pcd.common]\r
   gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel # ALWAYS_CONSUMED\r
index bee4b0ae43989d8486fa5b3e8acced18b6a9034f..82d1c39df0cdffea0b5bf35db0bbf4bc7e0139e7 100644 (file)
@@ -108,7 +108,7 @@ ShellCommandRunCd (
           ShellStatus = SHELL_NOT_FOUND;\r
         } else {\r
           Drive = GetFullyQualifiedPath(Directory);\r
-          ChopLastSlash(Drive);\r
+          PathRemoveLastItem(Drive);\r
         }\r
         if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {\r
           //\r
@@ -130,7 +130,7 @@ ShellCommandRunCd (
           ShellStatus = SHELL_NOT_FOUND;\r
         } else {\r
           Drive = GetFullyQualifiedPath(Directory);\r
-          while (ChopLastSlash(Drive)) ;\r
+          while (PathRemoveLastItem(Drive)) ;\r
         }\r
         if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {\r
           //\r
@@ -150,7 +150,7 @@ ShellCommandRunCd (
           ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));\r
           Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL), 0);\r
           if (*Param1 == L'\\') {\r
-            while (ChopLastSlash(Drive)) ;\r
+            while (PathRemoveLastItem(Drive)) ;\r
             Drive = StrnCatGrow(&Drive, &DriveSize, Param1+1, 0);\r
           } else {\r
             Drive = StrnCatGrow(&Drive, &DriveSize, Param1, 0);\r
index 8b30ac3122ae5db0a71aaa704d7b40b015c3c9bd..08f5514cf54be387f6dc4c6af6994af172afb1fc 100644 (file)
@@ -416,7 +416,7 @@ ValidateAndCopyFiles(
       break;\r
     }\r
 \r
-    CleanPath(DestPath);\r
+    PathCleanUpDirectories(DestPath);\r
 \r
     ShellPrintEx(-1, -1, HiiOutput, Node->FullName, DestPath);\r
 \r
@@ -619,7 +619,7 @@ ShellCommandRunCp (
           // now copy them all...\r
           //\r
           if (FileList != NULL && !IsListEmpty(&FileList->Link)) {\r
-            ShellStatus = ProcessValidateAndCopyFiles(FileList, ShellCommandCleanPath((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount)), SilentMode, RecursiveMode);\r
+            ShellStatus = ProcessValidateAndCopyFiles(FileList, PathCleanUpDirectories((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount)), SilentMode, RecursiveMode);\r
             Status = ShellCloseFileMetaArg(&FileList);\r
             if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {\r
               ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamCount), ShellStatus|MAX_BIT);\r
index ac71350ef460e37014df07ecbad623f7b38f7532..a93b54c4293d58f1855df611e4ee4e9992bcc0c0 100644 (file)
@@ -67,7 +67,7 @@ PrintLsOutput(
 \r
   CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);\r
   ASSERT(CorrectedPath != NULL);\r
-  ShellCommandCleanPath(CorrectedPath);\r
+  PathCleanUpDirectories(CorrectedPath);\r
 \r
   Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);\r
   if (EFI_ERROR(Status)) {\r
index dc9ef64d7f317c14fa77ff5b167411d6bebee051..5afcea23107fd62d9955d4447eaa171b25dfa170 100644 (file)
@@ -148,7 +148,7 @@ GetDestinationLocation(
       return (SHELL_OUT_OF_RESOURCES);\r
     }\r
     StrCpy(DestPath, Cwd);\r
-    while (ChopLastSlash(DestPath)) ;\r
+    while (PathRemoveLastItem(DestPath)) ;\r
     *DestPathPointer =  DestPath;\r
     return (SHELL_SUCCESS);\r
   }\r
@@ -268,7 +268,7 @@ ValidateAndMoveFiles(
   if (ShellStatus != SHELL_SUCCESS) {\r
     return (ShellStatus);\r
   }\r
-  DestPath = CleanPath(DestPath);\r
+  DestPath = PathCleanUpDirectories(DestPath);\r
 \r
   HiiOutput   = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);\r
   HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);\r
index fed233c33aea6cb4ece7960d52aa5d75dc638284..ce3d87ba502f745bf9e9a17f85e4c71c455bf053 100644 (file)
@@ -196,7 +196,7 @@ GetFullyQualifiedPath(
   }\r
   StrnCatGrow(&PathToReturn, &Size, Path, 0);\r
 \r
-  CleanPath(PathToReturn);\r
+  PathCleanUpDirectories(PathToReturn);\r
 \r
   while (PathToReturn[StrLen(PathToReturn)-1] == L'*') {\r
     PathToReturn[StrLen(PathToReturn)-1] = CHAR_NULL;\r
index 49e187fc7aaeed982555304f5c618e675a9ff489..80f6d59ee9f5bd5896a896cb51e04c1433b3c478 100644 (file)
@@ -46,6 +46,7 @@
 #include <Library/HiiLib.h>\r
 #include <Library/SortLib.h>\r
 #include <Library/FileHandleLib.h>\r
+#include <Library/PathLib.h>\r
 \r
 extern CONST  CHAR16                            mFileName[];\r
 extern        EFI_HANDLE                        gShellLevel2HiiHandle;\r
index 8b618b1f5fdc0185010d6ba34c4d9414dbf5ac49..52dc28feb2692f6cf66663af9a13fc13935aa4b2 100644 (file)
@@ -64,6 +64,7 @@
   PcdLib\r
   HiiLib\r
   HandleParsingLib\r
+  PathLib\r
 \r
 [Protocols]\r
   gEfiUnicodeCollation2ProtocolGuid                       # ALWAYS_CONSUMED\r
index c8fd0483342f08f5cca0d2228b4072c9d21b4792..e83b6cf50441aa405cad6e9c730b01d6c15160ac 100644 (file)
@@ -41,6 +41,9 @@
 \r
   ## @libraryclass   Provides advanced parsing functions\r
   HandleParsingLib|Include/Library/HandleParsingLib.h\r
+  \r
+  ## @libraryclass   Provides path manipulation functions\r
+  PathLib|Include/Library/PathLib.h\r
 \r
 [Guids]\r
   gEfiShellEnvironment2ExtGuid    = {0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87}}\r
index 6ac336179c89d2a97c01a67b2f4e9eaf3275c019..6b641155f2e842ff3c0d0847c461ab5fbbef9369 100644 (file)
@@ -48,6 +48,7 @@
   HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
   \r
   PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
+  PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf\r
 \r
 [LibraryClasses.ARM]\r
   #\r