2010-09-14 07:18:09 +02:00
|
|
|
/** @file
|
|
|
|
Main file for mv shell level 2 function.
|
|
|
|
|
2015-02-04 23:25:01 +01:00
|
|
|
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
|
2015-06-30 05:18:31 +02:00
|
|
|
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
|
2010-09-14 07:18:09 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "UefiShellLevel2CommandsLib.h"
|
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
/**
|
|
|
|
function to determine if a move is between file systems.
|
|
|
|
|
|
|
|
@param FullName [in] The name of the file to move.
|
|
|
|
@param Cwd [in] The current working directory
|
|
|
|
@param DestPath [in] The target location to move to
|
|
|
|
|
|
|
|
@retval TRUE The move is across file system.
|
|
|
|
@retval FALSE The move is within a file system.
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
EFIAPI
|
|
|
|
IsBetweenFileSystem(
|
|
|
|
IN CONST CHAR16 *FullName,
|
|
|
|
IN CONST CHAR16 *Cwd,
|
|
|
|
IN CONST CHAR16 *DestPath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR16 *Test;
|
|
|
|
CHAR16 *Test1;
|
|
|
|
UINTN Result;
|
|
|
|
|
|
|
|
Test = StrStr(FullName, L":");
|
|
|
|
if (Test == NULL && Cwd != NULL) {
|
|
|
|
Test = StrStr(Cwd, L":");
|
|
|
|
}
|
|
|
|
Test1 = StrStr(DestPath, L":");
|
|
|
|
if (Test1 == NULL && Cwd != NULL) {
|
|
|
|
Test1 = StrStr(Cwd, L":");
|
|
|
|
}
|
|
|
|
if (Test1 != NULL && Test != NULL) {
|
|
|
|
*Test = CHAR_NULL;
|
|
|
|
*Test1 = CHAR_NULL;
|
|
|
|
Result = StringNoCaseCompare(&FullName, &DestPath);
|
|
|
|
*Test = L':';
|
|
|
|
*Test1 = L':';
|
|
|
|
if (Result != 0) {
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
/**
|
|
|
|
Function to validate that moving a specific file (FileName) to a specific
|
|
|
|
location (DestPath) is valid.
|
|
|
|
|
|
|
|
This function will verify that the destination is not a subdirectory of
|
|
|
|
FullName, that the Current working Directory is not being moved, and that
|
|
|
|
the directory is not read only.
|
|
|
|
|
|
|
|
if the move is invalid this function will report the error to StdOut.
|
|
|
|
|
2014-10-14 03:16:38 +02:00
|
|
|
@param SourcePath [in] The name of the file to move.
|
|
|
|
@param Cwd [in] The current working directory
|
|
|
|
@param DestPath [in] The target location to move to
|
|
|
|
@param Attribute [in] The Attribute of the file
|
|
|
|
@param DestAttr [in] The Attribute of the destination
|
|
|
|
@param FileStatus [in] The Status of the file when opened
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
@retval TRUE The move is valid
|
|
|
|
@retval FALSE The move is not
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
EFIAPI
|
|
|
|
IsValidMove(
|
2014-10-02 18:40:49 +02:00
|
|
|
IN CONST CHAR16 *SourcePath,
|
2014-06-24 20:39:15 +02:00
|
|
|
IN CONST CHAR16 *Cwd,
|
|
|
|
IN CONST CHAR16 *DestPath,
|
|
|
|
IN CONST UINT64 Attribute,
|
2014-10-02 18:40:49 +02:00
|
|
|
IN CONST UINT64 DestAttr,
|
2014-06-24 20:39:15 +02:00
|
|
|
IN CONST EFI_STATUS FileStatus
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2014-10-02 18:40:49 +02:00
|
|
|
CHAR16 *DestPathCopy;
|
|
|
|
CHAR16 *DestPathWalker;
|
|
|
|
|
|
|
|
if (Cwd != NULL && StrCmp(SourcePath, Cwd) == 0) {
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
|
|
|
// Invalid move
|
|
|
|
//
|
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);
|
|
|
|
return (FALSE);
|
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// invalid to move read only or move to a read only destination
|
|
|
|
//
|
|
|
|
if (((Attribute & EFI_FILE_READ_ONLY) != 0)
|
|
|
|
|| (FileStatus == EFI_WRITE_PROTECTED)
|
|
|
|
|| ((DestAttr & EFI_FILE_READ_ONLY) != 0)
|
|
|
|
) {
|
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, SourcePath);
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
DestPathCopy = AllocateCopyPool(StrSize(DestPath), DestPath);
|
|
|
|
if (DestPathCopy == NULL) {
|
|
|
|
return (FALSE);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
for (DestPathWalker = DestPathCopy; *DestPathWalker == L'\\'; DestPathWalker++) ;
|
|
|
|
|
|
|
|
while(DestPathWalker != NULL && DestPathWalker[StrLen(DestPathWalker)-1] == L'\\') {
|
|
|
|
DestPathWalker[StrLen(DestPathWalker)-1] = CHAR_NULL;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
ASSERT(DestPathWalker != NULL);
|
|
|
|
ASSERT(SourcePath != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// If they're the same, or if source is "above" dest on file path tree
|
|
|
|
//
|
2015-07-01 03:46:20 +02:00
|
|
|
if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 ||
|
|
|
|
((StrStr(DestPathWalker, SourcePath) == DestPathWalker) &&
|
|
|
|
(DestPathWalker[StrLen(SourcePath)] == '\\')
|
|
|
|
)
|
|
|
|
) {
|
2010-09-14 07:18:09 +02:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
|
2014-10-02 18:40:49 +02:00
|
|
|
FreePool(DestPathCopy);
|
2010-09-14 07:18:09 +02:00
|
|
|
return (FALSE);
|
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
FreePool(DestPathCopy);
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to take a destination path that might contain wildcards and verify
|
|
|
|
that there is only a single possible target (IE we cant have wildcards that
|
|
|
|
have 2 possible destination).
|
|
|
|
|
|
|
|
if the result is sucessful the caller must free *DestPathPointer.
|
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
@param[in] DestParameter The original path to the destination.
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] DestPathPointer A pointer to the callee allocated final path.
|
|
|
|
@param[in] Cwd A pointer to the current working directory.
|
2014-10-14 03:16:38 +02:00
|
|
|
@param[in] SingleSource TRUE to have only one source file.
|
|
|
|
@param[in, out] DestAttr A pointer to the destination information attribute.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
@retval SHELL_INVALID_PARAMETER The DestParameter could not be resolved to a location.
|
|
|
|
@retval SHELL_INVALID_PARAMETER The DestParameter could be resolved to more than 1 location.
|
2011-10-10 19:26:25 +02:00
|
|
|
@retval SHELL_INVALID_PARAMETER Cwd is required and is NULL.
|
|
|
|
@retval SHELL_SUCCESS The operation was sucessful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
GetDestinationLocation(
|
2014-10-02 18:40:49 +02:00
|
|
|
IN CONST CHAR16 *DestParameter,
|
2010-09-14 07:18:09 +02:00
|
|
|
IN OUT CHAR16 **DestPathPointer,
|
2014-10-02 18:40:49 +02:00
|
|
|
IN CONST CHAR16 *Cwd,
|
|
|
|
IN CONST BOOLEAN SingleSource,
|
|
|
|
IN OUT UINT64 *DestAttr
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_SHELL_FILE_INFO *DestList;
|
|
|
|
EFI_SHELL_FILE_INFO *Node;
|
|
|
|
CHAR16 *DestPath;
|
|
|
|
UINTN NewSize;
|
2013-10-18 22:10:18 +02:00
|
|
|
UINTN CurrentSize;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
DestList = NULL;
|
|
|
|
DestPath = NULL;
|
2011-03-25 21:58:08 +01:00
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
ASSERT(DestAttr != NULL);
|
|
|
|
|
|
|
|
if (StrStr(DestParameter, L"\\") == DestParameter) {
|
2011-10-10 19:26:25 +02:00
|
|
|
if (Cwd == NULL) {
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
2011-03-25 21:58:08 +01:00
|
|
|
DestPath = AllocateZeroPool(StrSize(Cwd));
|
|
|
|
if (DestPath == NULL) {
|
|
|
|
return (SHELL_OUT_OF_RESOURCES);
|
|
|
|
}
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCpyS(DestPath, StrSize(Cwd) / sizeof(CHAR16), Cwd);
|
2011-07-01 00:58:53 +02:00
|
|
|
while (PathRemoveLastItem(DestPath)) ;
|
2013-10-18 22:10:18 +02:00
|
|
|
|
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
// Append DestParameter beyond '\' which may be present
|
2013-10-18 22:10:18 +02:00
|
|
|
//
|
|
|
|
CurrentSize = StrSize(DestPath);
|
2014-10-02 18:40:49 +02:00
|
|
|
StrnCatGrow(&DestPath, &CurrentSize, &DestParameter[1], 0);
|
2013-10-18 22:10:18 +02:00
|
|
|
|
2011-03-25 21:58:08 +01:00
|
|
|
*DestPathPointer = DestPath;
|
|
|
|
return (SHELL_SUCCESS);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
|
|
|
// get the destination path
|
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
ShellOpenFileMetaArg((CHAR16*)DestParameter, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
|
2010-09-14 07:18:09 +02:00
|
|
|
if (DestList == NULL || IsListEmpty(&DestList->Link)) {
|
|
|
|
//
|
|
|
|
// Not existing... must be renaming
|
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
if (StrStr(DestParameter, L":") == NULL) {
|
2011-10-10 19:26:25 +02:00
|
|
|
if (Cwd == NULL) {
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
2014-10-02 18:40:49 +02:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
|
2011-10-10 19:26:25 +02:00
|
|
|
return (SHELL_INVALID_PARAMETER);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
NewSize = StrSize(Cwd);
|
2014-10-02 18:40:49 +02:00
|
|
|
NewSize += StrSize(DestParameter);
|
2010-09-14 07:18:09 +02:00
|
|
|
DestPath = AllocateZeroPool(NewSize);
|
2010-10-04 18:30:40 +02:00
|
|
|
if (DestPath == NULL) {
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
|
|
|
return (SHELL_OUT_OF_RESOURCES);
|
|
|
|
}
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCpyS(DestPath, NewSize / sizeof(CHAR16), Cwd);
|
2014-10-02 18:40:49 +02:00
|
|
|
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestParameter[0] != L'\\') {
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCatS(DestPath, NewSize / sizeof(CHAR16), L"\\");
|
2014-10-02 18:40:49 +02:00
|
|
|
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestParameter[0] == L'\\') {
|
2010-09-14 07:18:09 +02:00
|
|
|
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
|
|
|
|
}
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCatS(DestPath, NewSize / sizeof(CHAR16), DestParameter);
|
2010-09-14 07:18:09 +02:00
|
|
|
} else {
|
|
|
|
ASSERT(DestPath == NULL);
|
2014-10-02 18:40:49 +02:00
|
|
|
DestPath = StrnCatGrow(&DestPath, NULL, DestParameter, 0);
|
2010-10-04 18:30:40 +02:00
|
|
|
if (DestPath == NULL) {
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
|
|
|
return (SHELL_OUT_OF_RESOURCES);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&DestList->Link);
|
2014-10-02 18:40:49 +02:00
|
|
|
*DestAttr = Node->Info->Attribute;
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
|
|
|
// Make sure there is only 1 node in the list.
|
|
|
|
//
|
|
|
|
if (!IsNodeAtEnd(&DestList->Link, &Node->Link)) {
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
|
2010-09-14 07:18:09 +02:00
|
|
|
return (SHELL_INVALID_PARAMETER);
|
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// If we are a directory or a single file, then one node is fine.
|
|
|
|
//
|
|
|
|
if (ShellIsDirectory(Node->FullName)==EFI_SUCCESS || SingleSource) {
|
2010-09-14 07:18:09 +02:00
|
|
|
DestPath = AllocateZeroPool(StrSize(Node->FullName)+sizeof(CHAR16));
|
2010-10-04 18:30:40 +02:00
|
|
|
if (DestPath == NULL) {
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
|
|
|
return (SHELL_OUT_OF_RESOURCES);
|
|
|
|
}
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCpyS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), Node->FullName);
|
|
|
|
StrCatS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), L"\\");
|
2010-09-14 07:18:09 +02:00
|
|
|
} else {
|
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
// cant move multiple files onto a single file.
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
|
2010-09-14 07:18:09 +02:00
|
|
|
return (SHELL_INVALID_PARAMETER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*DestPathPointer = DestPath;
|
|
|
|
ShellCloseFileMetaArg(&DestList);
|
|
|
|
|
|
|
|
return (SHELL_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2014-10-14 03:16:38 +02:00
|
|
|
/**
|
|
|
|
Function to do a move across file systems.
|
|
|
|
|
|
|
|
@param[in] Node A pointer to the file to be removed.
|
|
|
|
@param[in] DestPath A pointer to the destination file path.
|
|
|
|
@param[out] Resp A pointer to response from question. Pass back on looped calling
|
|
|
|
|
|
|
|
@retval SHELL_SUCCESS The source file was moved to the destination.
|
|
|
|
**/
|
2014-10-02 18:40:49 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MoveBetweenFileSystems(
|
|
|
|
IN EFI_SHELL_FILE_INFO *Node,
|
|
|
|
IN CONST CHAR16 *DestPath,
|
|
|
|
OUT VOID **Resp
|
|
|
|
)
|
|
|
|
{
|
2015-04-07 22:39:22 +02:00
|
|
|
SHELL_STATUS ShellStatus;
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// First we copy the file
|
|
|
|
//
|
2015-04-07 22:39:22 +02:00
|
|
|
ShellStatus = CopySingleFile (Node->FullName, DestPath, Resp, TRUE, L"mv");
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Check our result
|
|
|
|
//
|
2015-04-07 22:39:22 +02:00
|
|
|
if (ShellStatus == SHELL_SUCCESS) {
|
2014-10-02 18:40:49 +02:00
|
|
|
//
|
|
|
|
// The copy was successful. delete the source file.
|
|
|
|
//
|
|
|
|
CascadeDelete(Node, TRUE);
|
|
|
|
Node->Handle = NULL;
|
2015-04-07 22:39:22 +02:00
|
|
|
} else if (ShellStatus == SHELL_ABORTED) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
} else if (ShellStatus == SHELL_ACCESS_DENIED) {
|
|
|
|
return EFI_ACCESS_DENIED;
|
|
|
|
} else if (ShellStatus == SHELL_VOLUME_FULL) {
|
|
|
|
return EFI_VOLUME_FULL;
|
|
|
|
} else {
|
|
|
|
return EFI_UNSUPPORTED;
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
|
|
|
|
2015-04-07 22:39:22 +02:00
|
|
|
return (EFI_SUCCESS);
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
|
|
|
|
2014-10-14 03:16:38 +02:00
|
|
|
/**
|
|
|
|
Function to take the destination path and target file name to generate the full destination path.
|
|
|
|
|
|
|
|
@param[in] DestPath A pointer to the destination file path string.
|
|
|
|
@param[out] FullDestPath A pointer to the full destination path string.
|
|
|
|
@param[in] FileName Name string of the targe file.
|
|
|
|
|
|
|
|
@retval SHELL_SUCCESS the files were all moved.
|
|
|
|
@retval SHELL_INVALID_PARAMETER a parameter was invalid
|
|
|
|
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
|
|
|
|
**/
|
2014-10-02 18:40:49 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CreateFullDestPath(
|
|
|
|
IN CONST CHAR16 **DestPath,
|
|
|
|
OUT CHAR16 **FullDestPath,
|
|
|
|
IN CONST CHAR16 *FileName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Size;
|
|
|
|
if (FullDestPath == NULL || FileName == NULL || DestPath == NULL || *DestPath == NULL){
|
|
|
|
return (EFI_INVALID_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
Size = StrSize(*DestPath) + StrSize(FileName);
|
|
|
|
|
|
|
|
*FullDestPath = AllocateZeroPool(Size);
|
|
|
|
if (*FullDestPath == NULL){
|
|
|
|
return (EFI_OUT_OF_RESOURCES);
|
|
|
|
}
|
|
|
|
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCpyS(*FullDestPath, Size / sizeof(CHAR16), *DestPath);
|
2014-10-02 18:40:49 +02:00
|
|
|
if ((*FullDestPath)[StrLen(*FullDestPath)-1] != L'\\' && FileName[0] != L'\\') {
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCatS(*FullDestPath, Size / sizeof(CHAR16), L"\\");
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCatS(*FullDestPath, Size / sizeof(CHAR16), FileName);
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
return (EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2014-10-14 03:16:38 +02:00
|
|
|
/**
|
|
|
|
Function to do a move within a file system.
|
|
|
|
|
|
|
|
@param[in] Node A pointer to the file to be removed.
|
|
|
|
@param[in] DestPath A pointer to the destination file path.
|
|
|
|
@param[out] Resp A pointer to response from question. Pass back on looped calling.
|
|
|
|
|
|
|
|
@retval SHELL_SUCCESS The source file was moved to the destination.
|
|
|
|
@retval SHELL_OUT_OF_RESOURCES A memory allocation failed.
|
|
|
|
**/
|
2014-10-02 18:40:49 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MoveWithinFileSystems(
|
|
|
|
IN EFI_SHELL_FILE_INFO *Node,
|
|
|
|
IN CHAR16 *DestPath,
|
|
|
|
OUT VOID **Resp
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_FILE_INFO *NewFileInfo;
|
|
|
|
CHAR16 *TempLocation;
|
|
|
|
UINTN NewSize;
|
|
|
|
UINTN Length;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Chop off map info from DestPath
|
|
|
|
//
|
|
|
|
if ((TempLocation = StrStr(DestPath, L":")) != NULL) {
|
|
|
|
CopyMem(DestPath, TempLocation+1, StrSize(TempLocation+1));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// construct the new file info block
|
|
|
|
//
|
|
|
|
NewSize = StrSize(DestPath);
|
|
|
|
NewSize += StrSize(Node->FileName) + SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);
|
|
|
|
NewFileInfo = AllocateZeroPool(NewSize);
|
|
|
|
if (NewFileInfo == NULL) {
|
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
} else {
|
|
|
|
CopyMem(NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);
|
|
|
|
if (DestPath[0] != L'\\') {
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), L"\\");
|
|
|
|
StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
|
2014-10-02 18:40:49 +02:00
|
|
|
} else {
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
|
|
|
Length = StrLen(NewFileInfo->FileName);
|
|
|
|
if (Length > 0) {
|
|
|
|
Length--;
|
|
|
|
}
|
|
|
|
if (NewFileInfo->FileName[Length] == L'\\') {
|
|
|
|
if (Node->FileName[0] == L'\\') {
|
|
|
|
//
|
|
|
|
// Don't allow for double slashes. Eliminate one of them.
|
|
|
|
//
|
|
|
|
NewFileInfo->FileName[Length] = CHAR_NULL;
|
|
|
|
}
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), Node->FileName);
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
|
|
|
NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize(NewFileInfo->FileName);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Perform the move operation
|
|
|
|
//
|
|
|
|
Status = ShellSetFileInfo(Node->Handle, NewFileInfo);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free the info object we used...
|
|
|
|
//
|
|
|
|
FreePool(NewFileInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (Status);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
/**
|
|
|
|
function to take a list of files to move and a destination location and do
|
|
|
|
the verification and moving of those files to that location. This function
|
|
|
|
will report any errors to the user and continue to move the rest of the files.
|
|
|
|
|
|
|
|
@param[in] FileList A LIST_ENTRY* based list of files to move
|
2011-03-25 21:58:08 +01:00
|
|
|
@param[out] Resp pointer to response from question. Pass back on looped calling
|
2014-10-02 18:40:49 +02:00
|
|
|
@param[in] DestParameter the originally specified destination location
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
@retval SHELL_SUCCESS the files were all moved.
|
|
|
|
@retval SHELL_INVALID_PARAMETER a parameter was invalid
|
|
|
|
@retval SHELL_SECURITY_VIOLATION a security violation ocurred
|
|
|
|
@retval SHELL_WRITE_PROTECTED the destination was write protected
|
|
|
|
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ValidateAndMoveFiles(
|
2014-10-02 18:40:49 +02:00
|
|
|
IN EFI_SHELL_FILE_INFO *FileList,
|
2011-03-25 21:58:08 +01:00
|
|
|
OUT VOID **Resp,
|
2014-10-02 18:40:49 +02:00
|
|
|
IN CONST CHAR16 *DestParameter
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
CHAR16 *HiiOutput;
|
|
|
|
CHAR16 *HiiResultOk;
|
|
|
|
CHAR16 *DestPath;
|
2014-10-02 18:40:49 +02:00
|
|
|
CHAR16 *FullDestPath;
|
2010-09-14 07:18:09 +02:00
|
|
|
CONST CHAR16 *Cwd;
|
|
|
|
SHELL_STATUS ShellStatus;
|
2014-10-02 18:40:49 +02:00
|
|
|
EFI_SHELL_FILE_INFO *Node;
|
2011-03-25 21:58:08 +01:00
|
|
|
VOID *Response;
|
2014-10-02 18:40:49 +02:00
|
|
|
UINT64 Attr;
|
2014-09-17 09:58:31 +02:00
|
|
|
CHAR16 *CleanFilePathStr;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ASSERT(FileList != NULL);
|
2014-10-02 18:40:49 +02:00
|
|
|
ASSERT(DestParameter != NULL);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
DestPath = NULL;
|
|
|
|
FullDestPath = NULL;
|
|
|
|
Cwd = ShellGetCurrentDir(NULL);
|
|
|
|
Response = *Resp;
|
|
|
|
Attr = 0;
|
|
|
|
CleanFilePathStr = NULL;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);
|
2014-09-17 09:58:31 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
if (Status == EFI_OUT_OF_RESOURCES) {
|
|
|
|
return SHELL_OUT_OF_RESOURCES;
|
|
|
|
} else {
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
2014-09-17 09:58:31 +02:00
|
|
|
|
2014-09-23 08:20:59 +02:00
|
|
|
ASSERT (CleanFilePathStr != NULL);
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
|
|
|
// Get and validate the destination location
|
|
|
|
//
|
2014-10-09 03:25:32 +02:00
|
|
|
ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
|
2014-09-17 09:58:31 +02:00
|
|
|
FreePool (CleanFilePathStr);
|
2014-10-02 18:40:49 +02:00
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
if (ShellStatus != SHELL_SUCCESS) {
|
|
|
|
return (ShellStatus);
|
|
|
|
}
|
2011-07-01 00:58:53 +02:00
|
|
|
DestPath = PathCleanUpDirectories(DestPath);
|
2014-10-02 18:40:49 +02:00
|
|
|
if (DestPath == NULL) {
|
|
|
|
return (SHELL_OUT_OF_RESOURCES);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);
|
|
|
|
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
|
2014-10-02 18:40:49 +02:00
|
|
|
if (HiiOutput == NULL || HiiResultOk == NULL) {
|
|
|
|
SHELL_FREE_NON_NULL(DestPath);
|
|
|
|
SHELL_FREE_NON_NULL(HiiOutput);
|
|
|
|
SHELL_FREE_NON_NULL(HiiResultOk);
|
|
|
|
return (SHELL_OUT_OF_RESOURCES);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Go through the list of files and directories to move...
|
|
|
|
//
|
|
|
|
for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
|
|
|
|
; !IsNull(&FileList->Link, &Node->Link)
|
|
|
|
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
|
|
|
|
){
|
|
|
|
if (ShellGetExecutionBreakFlag()) {
|
|
|
|
break;
|
|
|
|
}
|
2014-06-24 20:39:15 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// These should never be NULL
|
|
|
|
//
|
2010-09-14 07:18:09 +02:00
|
|
|
ASSERT(Node->FileName != NULL);
|
|
|
|
ASSERT(Node->FullName != NULL);
|
2014-06-24 20:39:15 +02:00
|
|
|
ASSERT(Node->Info != NULL);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// skip the directory traversing stuff...
|
|
|
|
//
|
|
|
|
if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
SHELL_FREE_NON_NULL(FullDestPath);
|
|
|
|
FullDestPath = NULL;
|
|
|
|
if (ShellIsDirectory(DestPath)==EFI_SUCCESS) {
|
2014-10-08 22:38:05 +02:00
|
|
|
CreateFullDestPath((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
|
|
|
// Validate that the move is valid
|
|
|
|
//
|
2014-10-14 03:16:38 +02:00
|
|
|
if (!IsValidMove(Node->FullName, Cwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
|
2010-09-14 07:18:09 +02:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-10-14 03:16:38 +02:00
|
|
|
ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath!=NULL? FullDestPath:DestPath);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
// See if destination exists
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
2014-10-14 03:16:38 +02:00
|
|
|
if (!EFI_ERROR(ShellFileExists(FullDestPath!=NULL? FullDestPath:DestPath))) {
|
2014-10-02 18:40:49 +02:00
|
|
|
if (Response == NULL) {
|
|
|
|
ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
switch (*(SHELL_PROMPT_RESPONSE*)Response) {
|
|
|
|
case ShellPromptResponseNo:
|
|
|
|
FreePool(Response);
|
|
|
|
Response = NULL;
|
|
|
|
continue;
|
|
|
|
case ShellPromptResponseCancel:
|
|
|
|
*Resp = Response;
|
2010-10-04 18:30:40 +02:00
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
// indicate to stop everything
|
2010-10-04 18:30:40 +02:00
|
|
|
//
|
2014-10-02 18:40:49 +02:00
|
|
|
return (SHELL_ABORTED);
|
|
|
|
case ShellPromptResponseAll:
|
|
|
|
*Resp = Response;
|
|
|
|
break;
|
|
|
|
case ShellPromptResponseYes:
|
|
|
|
FreePool(Response);
|
|
|
|
Response = NULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FreePool(Response);
|
|
|
|
return SHELL_ABORTED;
|
2011-03-25 21:58:08 +01:00
|
|
|
}
|
2014-10-14 03:16:38 +02:00
|
|
|
Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
2011-03-25 21:58:08 +01:00
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
if (IsBetweenFileSystem(Node->FullName, Cwd, DestPath)) {
|
|
|
|
while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {
|
|
|
|
DestPath[StrLen(DestPath) - 1] = CHAR_NULL;
|
|
|
|
}
|
2014-10-14 03:16:38 +02:00
|
|
|
Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);
|
2014-10-02 18:40:49 +02:00
|
|
|
} else {
|
|
|
|
Status = MoveWithinFileSystems(Node, DestPath, &Response);
|
2015-04-07 22:39:22 +02:00
|
|
|
//
|
|
|
|
// Display error status
|
|
|
|
//
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
|
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
}
|
2011-03-25 21:58:08 +01:00
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
//
|
|
|
|
// Check our result
|
|
|
|
//
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
if (Status == EFI_SECURITY_VIOLATION) {
|
|
|
|
ShellStatus = SHELL_SECURITY_VIOLATION;
|
|
|
|
} else if (Status == EFI_WRITE_PROTECTED) {
|
|
|
|
ShellStatus = SHELL_WRITE_PROTECTED;
|
|
|
|
} else if (Status == EFI_OUT_OF_RESOURCES) {
|
|
|
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
|
|
|
} else if (Status == EFI_DEVICE_ERROR) {
|
|
|
|
ShellStatus = SHELL_DEVICE_ERROR;
|
|
|
|
} else if (Status == EFI_ACCESS_DENIED) {
|
|
|
|
ShellStatus = SHELL_ACCESS_DENIED;
|
2010-10-04 18:30:40 +02:00
|
|
|
}
|
2014-10-02 18:40:49 +02:00
|
|
|
} else {
|
|
|
|
ShellPrintEx(-1, -1, L"%s", HiiResultOk);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
} // main for loop
|
|
|
|
|
|
|
|
SHELL_FREE_NON_NULL(FullDestPath);
|
|
|
|
SHELL_FREE_NON_NULL(DestPath);
|
|
|
|
SHELL_FREE_NON_NULL(HiiOutput);
|
|
|
|
SHELL_FREE_NON_NULL(HiiResultOk);
|
2010-09-14 07:18:09 +02:00
|
|
|
return (ShellStatus);
|
|
|
|
}
|
|
|
|
|
2011-03-25 21:58:08 +01:00
|
|
|
/**
|
|
|
|
Function for 'mv' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
2010-09-14 07:18:09 +02:00
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunMv (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Package;
|
|
|
|
CHAR16 *ProblemParam;
|
|
|
|
SHELL_STATUS ShellStatus;
|
|
|
|
UINTN ParamCount;
|
|
|
|
UINTN LoopCounter;
|
|
|
|
EFI_SHELL_FILE_INFO *FileList;
|
2011-03-25 21:58:08 +01:00
|
|
|
VOID *Response;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ProblemParam = NULL;
|
|
|
|
ShellStatus = SHELL_SUCCESS;
|
|
|
|
ParamCount = 0;
|
|
|
|
FileList = NULL;
|
2011-03-25 21:58:08 +01:00
|
|
|
Response = NULL;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// initialize the shell lib (we must be in non-auto-init...)
|
|
|
|
//
|
|
|
|
Status = ShellInitialize();
|
|
|
|
ASSERT_EFI_ERROR(Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// parse the command line
|
|
|
|
//
|
|
|
|
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);
|
2010-09-14 07:18:09 +02:00
|
|
|
FreePool(ProblemParam);
|
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// check for "-?"
|
|
|
|
//
|
|
|
|
if (ShellCommandLineGetFlag(Package, L"-?")) {
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ParamCount = ShellCommandLineGetCount(Package)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
//
|
|
|
|
// we have insufficient parameters
|
|
|
|
//
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");
|
2010-09-14 07:18:09 +02:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
//
|
|
|
|
// must have valid CWD for single parameter...
|
|
|
|
//
|
|
|
|
if (ShellGetCurrentDir(NULL) == NULL){
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");
|
2010-09-14 07:18:09 +02:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
|
|
|
if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1));
|
2010-09-14 07:18:09 +02:00
|
|
|
ShellStatus = SHELL_NOT_FOUND;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// ValidateAndMoveFiles will report errors to the screen itself
|
|
|
|
//
|
2011-03-25 21:58:08 +01:00
|
|
|
ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
///@todo make sure this works with error half way through and continues...
|
2011-03-25 21:58:08 +01:00
|
|
|
for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount ; LoopCounter++) {
|
2010-09-14 07:18:09 +02:00
|
|
|
if (ShellGetExecutionBreakFlag()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
|
|
|
if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, LoopCounter));
|
2010-09-14 07:18:09 +02:00
|
|
|
ShellStatus = SHELL_NOT_FOUND;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// ValidateAndMoveFiles will report errors to the screen itself
|
|
|
|
// Only change ShellStatus if it's sucessful
|
|
|
|
//
|
|
|
|
if (ShellStatus == SHELL_SUCCESS) {
|
2011-03-25 21:58:08 +01:00
|
|
|
ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
|
2010-09-14 07:18:09 +02:00
|
|
|
} else {
|
2011-03-25 21:58:08 +01:00
|
|
|
ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
|
|
|
|
Status = ShellCloseFileMetaArg(&FileList);
|
|
|
|
if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
|
|
|
|
ShellStatus = SHELL_ACCESS_DENIED;
|
2015-02-03 22:24:21 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1), ShellStatus|MAX_BIT);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} // switch on parameter count
|
|
|
|
|
|
|
|
if (FileList != NULL) {
|
|
|
|
ShellCloseFileMetaArg(&FileList);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// free the command line package
|
|
|
|
//
|
|
|
|
ShellCommandLineFreeVarList (Package);
|
|
|
|
}
|
|
|
|
|
2011-03-25 21:58:08 +01:00
|
|
|
SHELL_FREE_NON_NULL(Response);
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
if (ShellGetExecutionBreakFlag()) {
|
|
|
|
return (SHELL_ABORTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ShellStatus);
|
|
|
|
}
|