X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel2CommandsLib%2FRm.c;h=288e7666a819ef9f903a079a149f993398ed3f51;hb=2d70c90d2e8bf4405c5c16c0c7ea5b2446d1517a;hp=e9a3ff4fdc0a9aa84afc4cc97ed00c02aed5b2f5;hpb=5a51ad8d20911f31b526a566945f1915c2c41db2;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c index e9a3ff4fdc..288e7666a8 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c @@ -1,7 +1,8 @@ /** @file Main file for attrib shell level 2 function. - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -28,11 +29,11 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { @retval FALSE The directory has at least 1 file or directory in it. **/ BOOLEAN -EFIAPI IsDirectoryEmpty ( IN EFI_HANDLE FileHandle ) { + EFI_STATUS Status; EFI_FILE_INFO *FileInfo; BOOLEAN NoFile; BOOLEAN RetVal; @@ -41,8 +42,8 @@ IsDirectoryEmpty ( NoFile = FALSE; FileInfo = NULL; - for (FileHandleFindFirstFile(FileHandle, &FileInfo) - ; !NoFile + for (Status = FileHandleFindFirstFile(FileHandle, &FileInfo) + ; !NoFile && !EFI_ERROR (Status) ; FileHandleFindNextFile(FileHandle, FileInfo, &NoFile) ){ if (StrStr(FileInfo->FileName, L".") != FileInfo->FileName @@ -65,7 +66,6 @@ IsDirectoryEmpty ( @retval SHELL_DEVICE_ERROR A device error occured reading this Node. **/ SHELL_STATUS -EFIAPI CascadeDelete( IN EFI_SHELL_FILE_INFO *Node, IN CONST BOOLEAN Quiet @@ -85,7 +85,7 @@ CascadeDelete( Status = EFI_SUCCESS; if ((Node->Info->Attribute & EFI_FILE_READ_ONLY) == EFI_FILE_READ_ONLY) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DETELE_RO), gShellLevel2HiiHandle, Node->FullName); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DETELE_RO), gShellLevel2HiiHandle, L"rm", Node->FullName); return (SHELL_ACCESS_DENIED); } @@ -131,9 +131,9 @@ CascadeDelete( if (TempName == NULL) { ShellStatus = SHELL_OUT_OF_RESOURCES; } else { - StrnCpy(TempName, Node->FullName, NewSize/sizeof(CHAR16) -1); + StrCpyS(TempName, NewSize/sizeof(CHAR16), Node->FullName); TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL; - StrnCat(TempName, Node2->FullName, NewSize/sizeof(CHAR16) -1 - StrLen(TempName)); + StrCatS(TempName, NewSize/sizeof(CHAR16), Node2->FullName); FreePool((VOID*)Node2->FullName); Node2->FullName = TempName; @@ -187,14 +187,13 @@ CascadeDelete( } /** - Determins if a Node is a valid delete target. Will prevent deleting the root directory. + Determines if a Node is a valid delete target. Will prevent deleting the root directory. @param[in] List RESERVED. Not used. @param[in] Node The node to analyze. @param[in] Package RESERVED. Not used. **/ BOOLEAN -EFIAPI IsValidDeleteTarget( IN CONST EFI_SHELL_FILE_INFO *List, IN CONST EFI_SHELL_FILE_INFO *Node, @@ -230,7 +229,9 @@ IsValidDeleteTarget( Pattern = NULL; SearchString = NULL; Size = 0; - Pattern = StrnCatGrow(&Pattern , NULL, TempLocation , 0); + Pattern = StrnCatGrow(&Pattern, &Size, TempLocation , 0); + Pattern = StrnCatGrow(&Pattern, &Size, L"\\" , 0); + Size = 0; SearchString = StrnCatGrow(&SearchString, &Size, Node->FullName, 0); if (!EFI_ERROR(ShellIsDirectory(SearchString))) { SearchString = StrnCatGrow(&SearchString, &Size, L"\\", 0); @@ -291,7 +292,7 @@ ShellCommandRunRm ( Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); if (EFI_ERROR(Status)) { if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"rm", ProblemParam); FreePool(ProblemParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -308,7 +309,7 @@ ShellCommandRunRm ( // // we insufficient parameters // - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"rm"); ShellStatus = SHELL_INVALID_PARAMETER; } else { // @@ -321,7 +322,7 @@ ShellCommandRunRm ( ){ Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList); if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, (CHAR16*)Param); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"rm", (CHAR16*)Param); ShellStatus = SHELL_NOT_FOUND; break; }