]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
1.Add code to check the pointer 'CorrectedPath' in Ls.c line 460 before referenced...
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Rm.c
index d167b36fb4507eb1d5362832a17c04939cc41d1c..c1e01426f8076f49ff38bb218a3f664a451d1baa 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for attrib shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2013, 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
@@ -33,7 +33,6 @@ IsDirectoryEmpty (
   IN EFI_HANDLE   FileHandle\r
   )\r
 {\r
-  EFI_STATUS      Status;\r
   EFI_FILE_INFO   *FileInfo;\r
   BOOLEAN         NoFile;\r
   BOOLEAN         RetVal;\r
@@ -41,9 +40,9 @@ IsDirectoryEmpty (
   RetVal = TRUE;\r
   NoFile = FALSE;\r
 \r
-  for (Status = FileHandleFindFirstFile(FileHandle, &FileInfo)\r
+  for (FileHandleFindFirstFile(FileHandle, &FileInfo)\r
     ;  !NoFile\r
-    ;  Status = FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)\r
+    ;  FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)\r
    ){\r
     if (StrStr(FileInfo->FileName, L".") != FileInfo->FileName\r
       &&StrStr(FileInfo->FileName, L"..") != FileInfo->FileName) {\r
@@ -76,6 +75,7 @@ CascadeDelete(
   EFI_SHELL_FILE_INFO   *Node2;\r
   EFI_STATUS            Status;\r
   SHELL_PROMPT_RESPONSE *Resp;\r
+  CHAR16                *TempName;\r
 \r
   Resp                  = NULL;\r
   ShellStatus           = SHELL_SUCCESS;\r
@@ -92,7 +92,6 @@ CascadeDelete(
       if (!Quiet) {\r
         Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_RM_LOG_DELETE_CONF), gShellLevel2HiiHandle, Node->FullName);\r
         Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);\r
-        ASSERT_EFI_ERROR(Status);\r
         ASSERT(Resp != NULL);\r
         if (EFI_ERROR(Status) || *Resp != ShellPromptResponseYes) {\r
           SHELL_FREE_NON_NULL(Resp);\r
@@ -121,7 +120,31 @@ CascadeDelete(
           continue;\r
         }\r
         Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);\r
-        ShellStatus = CascadeDelete(Node2, Quiet);\r
+        if (EFI_ERROR(Node2->Status) && StrStr(Node2->FileName, L":") == NULL) {\r
+          //\r
+          // Update the node filename to have full path with file system identifier\r
+          //\r
+          TempName = AllocateZeroPool(StrSize(Node->FullName) + StrSize(Node2->FullName));\r
+          if (TempName == NULL) {\r
+            ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+          } else {\r
+            StrCpy(TempName, Node->FullName);\r
+            TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;\r
+            StrCat(TempName, Node2->FullName);\r
+            FreePool((VOID*)Node2->FullName);\r
+            Node2->FullName = TempName;\r
+\r
+            //\r
+            // Now try again to open the file\r
+            //\r
+            Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);\r
+          }\r
+        }\r
+        if (!EFI_ERROR(Node2->Status)) {\r
+          ShellStatus = CascadeDelete(Node2, Quiet);\r
+        } else if (ShellStatus == SHELL_SUCCESS) {\r
+          ShellStatus = (SHELL_STATUS)(Node2->Status&(~0x80000000));\r
+        }\r
         if (ShellStatus != SHELL_SUCCESS) {\r
           if (List!=NULL) {\r
             gEfiShellProtocol->FreeFileList(&List);\r