Main file for cp shell level 2 function.\r
\r
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, 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
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed\r
**/\r
SHELL_STATUS\r
-EFIAPI\r
ValidateAndCopyFiles(\r
IN CONST EFI_SHELL_FILE_INFO *FileList,\r
IN CONST CHAR16 *DestDir,\r
@retval SHELL_SUCCESS The source file was copied to the destination\r
**/\r
SHELL_STATUS\r
-EFIAPI\r
CopySingleFile(\r
IN CONST CHAR16 *Source,\r
IN CONST CHAR16 *Dest,\r
// copy data between files\r
//\r
Buffer = AllocateZeroPool(ReadSize);\r
- ASSERT(Buffer != NULL);\r
+ if (Buffer == NULL) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, CmdName);\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ }\r
while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) {\r
Status = ShellReadFile(SourceHandle, &ReadSize, Buffer);\r
if (!EFI_ERROR(Status)) {\r
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed\r
**/\r
SHELL_STATUS\r
-EFIAPI\r
ValidateAndCopyFiles(\r
IN CONST EFI_SHELL_FILE_INFO *FileList,\r
IN CONST CHAR16 *DestDir,\r
@retval SHELL_SUCCESS The operation was successful.\r
**/\r
SHELL_STATUS\r
-EFIAPI\r
ProcessValidateAndCopyFiles(\r
IN EFI_SHELL_FILE_INFO *FileList,\r
IN CONST CHAR16 *DestDir,\r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
- ASSERT (FullCwd != NULL);\r
- StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
- ShellStatus = ProcessValidateAndCopyFiles(FileList, FullCwd, SilentMode, RecursiveMode);\r
- FreePool(FullCwd);\r
+ if (FullCwd == NULL) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"cp");\r
+ ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+ } else {\r
+ StrCpyS (FullCwd, StrSize (Cwd) / sizeof (CHAR16) + 1, Cwd);\r
+ ShellStatus = ProcessValidateAndCopyFiles (FileList, FullCwd, SilentMode, RecursiveMode);\r
+ FreePool (FullCwd);\r
+ }\r
}\r
}\r
\r