]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Refactor change to current file system
authorJaben Carsey <jaben.carsey@intel.com>
Fri, 13 Dec 2013 18:45:43 +0000 (18:45 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Dec 2013 18:45:43 +0000 (18:45 +0000)
This moves the initialization for handling file system changes into a separate function.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14983 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c

index b3dc8766ee64b2dc4614f67e5586426949fe3cdd..0cf09ec76b70b07d5aa62e227514449f52984888 100644 (file)
@@ -1618,6 +1618,43 @@ ProcessNewSplitCommandLine(
   }\r
   return (Status);\r
 }\r
+\r
+/**\r
+  Handle a request to change the current file system\r
+\r
+  @param[in] CmdLine  The passed in command line\r
+\r
+  @retval EFI_SUCCESS The operation was successful\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ChangeMappedDrive(\r
+  IN CONST CHAR16 *CmdLine\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+  Status = EFI_SUCCESS;\r
+\r
+  //\r
+  // make sure we are the right operation\r
+  //\r
+  ASSERT(CmdLine[(StrLen(CmdLine)-1)] == L':' && StrStr(CmdLine, L" ") == NULL);\r
+  \r
+  //\r
+  // Call the protocol API to do the work\r
+  //\r
+  Status = ShellInfoObject.NewEfiShellProtocol->SetCurDir(NULL, CmdLine);\r
+\r
+  //\r
+  // Report any errors\r
+  //\r
+  if (EFI_ERROR(Status)) {\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_MAPPING), ShellInfoObject.HiiHandle, CmdLine);\r
+  }\r
+\r
+  return (Status);\r
+}\r
+\r
 /**\r
   Function will process and run a command line.\r
 \r
@@ -1702,19 +1739,16 @@ RunCommand(
   if (ContainsSplit(CleanOriginal)) {\r
     Status = ProcessNewSplitCommandLine(CleanOriginal);\r
   } else {\r
-\r
     //\r
     // If this is a mapped drive change handle that...\r
     //\r
     if (CleanOriginal[(StrLen(CleanOriginal)-1)] == L':' && StrStr(CleanOriginal, L" ") == NULL) {\r
-      Status = ShellInfoObject.NewEfiShellProtocol->SetCurDir(NULL, CleanOriginal);\r
-      if (EFI_ERROR(Status)) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_MAPPING), ShellInfoObject.HiiHandle, CleanOriginal);\r
-      }\r
-      FreePool(CleanOriginal);\r
+      Status = ChangeMappedDrive(CleanOriginal);\r
+      SHELL_FREE_NON_NULL(CleanOriginal);\r
       return (Status);\r
     }\r
 \r
+\r
     ///@todo update this section to divide into 3 ways - run internal command, run split (above), and run an external file...\r
     ///      We waste a lot of time doing processing like StdIn,StdOut,Argv,Argc for things that are external files...\r
 \r