ShellPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ShellPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
c411b485b6
commit
47d20b54f9
@ -20,34 +20,37 @@
|
||||
@retval FALSE The move is within a file system.
|
||||
**/
|
||||
BOOLEAN
|
||||
IsBetweenFileSystem(
|
||||
IN CONST CHAR16 *FullName,
|
||||
IN CONST CHAR16 *Cwd,
|
||||
IN CONST CHAR16 *DestPath
|
||||
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":");
|
||||
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":");
|
||||
|
||||
Test1 = StrStr (DestPath, L":");
|
||||
if ((Test1 == NULL) && (Cwd != NULL)) {
|
||||
Test1 = StrStr (Cwd, L":");
|
||||
}
|
||||
if (Test1 != NULL && Test != NULL) {
|
||||
*Test = CHAR_NULL;
|
||||
|
||||
if ((Test1 != NULL) && (Test != NULL)) {
|
||||
*Test = CHAR_NULL;
|
||||
*Test1 = CHAR_NULL;
|
||||
Result = StringNoCaseCompare(&FullName, &DestPath);
|
||||
*Test = L':';
|
||||
Result = StringNoCaseCompare (&FullName, &DestPath);
|
||||
*Test = L':';
|
||||
*Test1 = L':';
|
||||
if (Result != 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -67,14 +70,14 @@ IsBetweenFileSystem(
|
||||
@retval FALSE The source path is invalid.
|
||||
**/
|
||||
BOOLEAN
|
||||
IsSoucePathValid(
|
||||
IN CONST CHAR16* SrcPath,
|
||||
IN CONST CHAR16* CwdPath
|
||||
IsSoucePathValid (
|
||||
IN CONST CHAR16 *SrcPath,
|
||||
IN CONST CHAR16 *CwdPath
|
||||
)
|
||||
{
|
||||
CHAR16* SrcPathBuffer;
|
||||
CHAR16* CwdPathBuffer;
|
||||
BOOLEAN Ret;
|
||||
CHAR16 *SrcPathBuffer;
|
||||
CHAR16 *CwdPathBuffer;
|
||||
BOOLEAN Ret;
|
||||
|
||||
ASSERT (CwdPath != NULL);
|
||||
if (SrcPath == NULL) {
|
||||
@ -90,14 +93,14 @@ IsSoucePathValid(
|
||||
|
||||
CwdPathBuffer = AllocateCopyPool (StrSize (CwdPath), CwdPath);
|
||||
if (CwdPathBuffer == NULL) {
|
||||
FreePool(SrcPathBuffer);
|
||||
FreePool (SrcPathBuffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gUnicodeCollation->StrUpr (gUnicodeCollation, SrcPathBuffer);
|
||||
gUnicodeCollation->StrUpr (gUnicodeCollation, CwdPathBuffer);
|
||||
|
||||
if (SrcPathBuffer[StrLen (SrcPathBuffer) -1 ] == L'\\') {
|
||||
if (SrcPathBuffer[StrLen (SrcPathBuffer) -1] == L'\\') {
|
||||
SrcPathBuffer[StrLen (SrcPathBuffer) - 1] = CHAR_NULL;
|
||||
}
|
||||
|
||||
@ -105,10 +108,11 @@ IsSoucePathValid(
|
||||
CwdPathBuffer[StrLen (CwdPathBuffer) - 1] = CHAR_NULL;
|
||||
}
|
||||
|
||||
if (StrCmp (CwdPathBuffer, SrcPathBuffer) == 0 ||
|
||||
if ((StrCmp (CwdPathBuffer, SrcPathBuffer) == 0) ||
|
||||
((StrStr (CwdPathBuffer, SrcPathBuffer) == CwdPathBuffer) &&
|
||||
(CwdPathBuffer[StrLen (SrcPathBuffer)] == L'\\'))
|
||||
) {
|
||||
)
|
||||
{
|
||||
Ret = FALSE;
|
||||
}
|
||||
|
||||
@ -139,13 +143,13 @@ IsSoucePathValid(
|
||||
@retval FALSE The move is not
|
||||
**/
|
||||
BOOLEAN
|
||||
IsValidMove(
|
||||
IN CONST CHAR16 *SourcePath,
|
||||
IN CONST CHAR16 *Cwd,
|
||||
IN CONST CHAR16 *DestPath,
|
||||
IN CONST UINT64 Attribute,
|
||||
IN CONST UINT64 DestAttr,
|
||||
IN CONST EFI_STATUS FileStatus
|
||||
IsValidMove (
|
||||
IN CONST CHAR16 *SourcePath,
|
||||
IN CONST CHAR16 *Cwd,
|
||||
IN CONST CHAR16 *DestPath,
|
||||
IN CONST UINT64 Attribute,
|
||||
IN CONST UINT64 DestAttr,
|
||||
IN CONST EFI_STATUS FileStatus
|
||||
)
|
||||
{
|
||||
CHAR16 *DestPathCopy;
|
||||
@ -156,7 +160,7 @@ IsValidMove(
|
||||
//
|
||||
// Invalid move
|
||||
//
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_MV_INV_CWD), gShellLevel2HiiHandle);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -164,41 +168,45 @@ IsValidMove(
|
||||
//
|
||||
// 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);
|
||||
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);
|
||||
DestPathCopy = AllocateCopyPool (StrSize (DestPath), DestPath);
|
||||
if (DestPathCopy == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
for (DestPathWalker = DestPathCopy; *DestPathWalker == L'\\'; DestPathWalker++) ;
|
||||
|
||||
while(DestPathWalker != NULL && DestPathWalker[StrLen(DestPathWalker)-1] == L'\\') {
|
||||
DestPathWalker[StrLen(DestPathWalker)-1] = CHAR_NULL;
|
||||
for (DestPathWalker = DestPathCopy; *DestPathWalker == L'\\'; DestPathWalker++) {
|
||||
}
|
||||
|
||||
ASSERT(DestPathWalker != NULL);
|
||||
ASSERT(SourcePath != NULL);
|
||||
while (DestPathWalker != NULL && DestPathWalker[StrLen (DestPathWalker)-1] == L'\\') {
|
||||
DestPathWalker[StrLen (DestPathWalker)-1] = CHAR_NULL;
|
||||
}
|
||||
|
||||
ASSERT (DestPathWalker != NULL);
|
||||
ASSERT (SourcePath != NULL);
|
||||
|
||||
//
|
||||
// If they're the same, or if source is "above" dest on file path tree
|
||||
//
|
||||
if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 ||
|
||||
((StrStr(DestPathWalker, SourcePath) == DestPathWalker) &&
|
||||
(DestPathWalker[StrLen(SourcePath)] == '\\')
|
||||
)
|
||||
) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
|
||||
FreePool(DestPathCopy);
|
||||
if ((StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0) ||
|
||||
((StrStr (DestPathWalker, SourcePath) == DestPathWalker) &&
|
||||
(DestPathWalker[StrLen (SourcePath)] == '\\')
|
||||
)
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
|
||||
FreePool (DestPathCopy);
|
||||
return (FALSE);
|
||||
}
|
||||
FreePool(DestPathCopy);
|
||||
|
||||
FreePool (DestPathCopy);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
@ -222,116 +230,124 @@ IsValidMove(
|
||||
@retval SHELL_SUCCESS The operation was sucessful.
|
||||
**/
|
||||
SHELL_STATUS
|
||||
GetDestinationLocation(
|
||||
IN CONST CHAR16 *DestParameter,
|
||||
IN OUT CHAR16 **DestPathPointer,
|
||||
IN CONST CHAR16 *Cwd,
|
||||
IN CONST BOOLEAN SingleSource,
|
||||
IN OUT UINT64 *DestAttr
|
||||
GetDestinationLocation (
|
||||
IN CONST CHAR16 *DestParameter,
|
||||
IN OUT CHAR16 **DestPathPointer,
|
||||
IN CONST CHAR16 *Cwd,
|
||||
IN CONST BOOLEAN SingleSource,
|
||||
IN OUT UINT64 *DestAttr
|
||||
)
|
||||
{
|
||||
EFI_SHELL_FILE_INFO *DestList;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
CHAR16 *DestPath;
|
||||
UINTN NewSize;
|
||||
UINTN CurrentSize;
|
||||
EFI_SHELL_FILE_INFO *DestList;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
CHAR16 *DestPath;
|
||||
UINTN NewSize;
|
||||
UINTN CurrentSize;
|
||||
|
||||
DestList = NULL;
|
||||
DestPath = NULL;
|
||||
|
||||
ASSERT(DestAttr != NULL);
|
||||
ASSERT (DestAttr != NULL);
|
||||
|
||||
if (StrStr(DestParameter, L"\\") == DestParameter) {
|
||||
if (StrStr (DestParameter, L"\\") == DestParameter) {
|
||||
if (Cwd == NULL) {
|
||||
return SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
DestPath = AllocateZeroPool(StrSize(Cwd));
|
||||
|
||||
DestPath = AllocateZeroPool (StrSize (Cwd));
|
||||
if (DestPath == NULL) {
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
StrCpyS(DestPath, StrSize(Cwd) / sizeof(CHAR16), Cwd);
|
||||
while (PathRemoveLastItem(DestPath)) ;
|
||||
|
||||
StrCpyS (DestPath, StrSize (Cwd) / sizeof (CHAR16), Cwd);
|
||||
while (PathRemoveLastItem (DestPath)) {
|
||||
}
|
||||
|
||||
//
|
||||
// Append DestParameter beyond '\' which may be present
|
||||
//
|
||||
CurrentSize = StrSize(DestPath);
|
||||
StrnCatGrow(&DestPath, &CurrentSize, &DestParameter[1], 0);
|
||||
CurrentSize = StrSize (DestPath);
|
||||
StrnCatGrow (&DestPath, &CurrentSize, &DestParameter[1], 0);
|
||||
|
||||
*DestPathPointer = DestPath;
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
//
|
||||
// get the destination path
|
||||
//
|
||||
ShellOpenFileMetaArg((CHAR16*)DestParameter, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
|
||||
if (DestList == NULL || IsListEmpty(&DestList->Link)) {
|
||||
ShellOpenFileMetaArg ((CHAR16 *)DestParameter, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
|
||||
if ((DestList == NULL) || IsListEmpty (&DestList->Link)) {
|
||||
//
|
||||
// Not existing... must be renaming
|
||||
//
|
||||
if (StrStr(DestParameter, L":") == NULL) {
|
||||
if (StrStr (DestParameter, L":") == NULL) {
|
||||
if (Cwd == NULL) {
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
NewSize = StrSize(Cwd);
|
||||
NewSize += StrSize(DestParameter);
|
||||
DestPath = AllocateZeroPool(NewSize);
|
||||
|
||||
NewSize = StrSize (Cwd);
|
||||
NewSize += StrSize (DestParameter);
|
||||
DestPath = AllocateZeroPool (NewSize);
|
||||
if (DestPath == NULL) {
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
StrCpyS(DestPath, NewSize / sizeof(CHAR16), Cwd);
|
||||
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestParameter[0] != L'\\') {
|
||||
StrCatS(DestPath, NewSize / sizeof(CHAR16), L"\\");
|
||||
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestParameter[0] == L'\\') {
|
||||
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
|
||||
|
||||
StrCpyS (DestPath, NewSize / sizeof (CHAR16), Cwd);
|
||||
if ((DestPath[StrLen (DestPath)-1] != L'\\') && (DestParameter[0] != L'\\')) {
|
||||
StrCatS (DestPath, NewSize / sizeof (CHAR16), L"\\");
|
||||
} else if ((DestPath[StrLen (DestPath)-1] == L'\\') && (DestParameter[0] == L'\\')) {
|
||||
((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL;
|
||||
}
|
||||
StrCatS(DestPath, NewSize / sizeof(CHAR16), DestParameter);
|
||||
|
||||
StrCatS (DestPath, NewSize / sizeof (CHAR16), DestParameter);
|
||||
} else {
|
||||
ASSERT(DestPath == NULL);
|
||||
DestPath = StrnCatGrow(&DestPath, NULL, DestParameter, 0);
|
||||
ASSERT (DestPath == NULL);
|
||||
DestPath = StrnCatGrow (&DestPath, NULL, DestParameter, 0);
|
||||
if (DestPath == NULL) {
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&DestList->Link);
|
||||
Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&DestList->Link);
|
||||
*DestAttr = Node->Info->Attribute;
|
||||
//
|
||||
// Make sure there is only 1 node in the list.
|
||||
//
|
||||
if (!IsNodeAtEnd(&DestList->Link, &Node->Link)) {
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
|
||||
if (!IsNodeAtEnd (&DestList->Link, &Node->Link)) {
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
//
|
||||
// If we are a directory or a single file, then one node is fine.
|
||||
//
|
||||
if (ShellIsDirectory(Node->FullName)==EFI_SUCCESS || SingleSource) {
|
||||
DestPath = AllocateZeroPool(StrSize(Node->FullName)+sizeof(CHAR16));
|
||||
if ((ShellIsDirectory (Node->FullName) == EFI_SUCCESS) || SingleSource) {
|
||||
DestPath = AllocateZeroPool (StrSize (Node->FullName)+sizeof (CHAR16));
|
||||
if (DestPath == NULL) {
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
StrCpyS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), Node->FullName);
|
||||
StrCatS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), L"\\");
|
||||
|
||||
StrCpyS (DestPath, (StrSize (Node->FullName)+sizeof (CHAR16)) / sizeof (CHAR16), Node->FullName);
|
||||
StrCatS (DestPath, (StrSize (Node->FullName)+sizeof (CHAR16)) / sizeof (CHAR16), L"\\");
|
||||
} else {
|
||||
//
|
||||
// cant move multiple files onto a single file.
|
||||
//
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
*DestPathPointer = DestPath;
|
||||
ShellCloseFileMetaArg(&DestList);
|
||||
ShellCloseFileMetaArg (&DestList);
|
||||
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
@ -346,13 +362,13 @@ GetDestinationLocation(
|
||||
@retval SHELL_SUCCESS The source file was moved to the destination.
|
||||
**/
|
||||
EFI_STATUS
|
||||
MoveBetweenFileSystems(
|
||||
MoveBetweenFileSystems (
|
||||
IN EFI_SHELL_FILE_INFO *Node,
|
||||
IN CONST CHAR16 *DestPath,
|
||||
OUT VOID **Resp
|
||||
)
|
||||
{
|
||||
SHELL_STATUS ShellStatus;
|
||||
SHELL_STATUS ShellStatus;
|
||||
|
||||
//
|
||||
// First we copy the file
|
||||
@ -366,7 +382,7 @@ MoveBetweenFileSystems(
|
||||
//
|
||||
// The copy was successful. delete the source file.
|
||||
//
|
||||
CascadeDelete(Node, TRUE);
|
||||
CascadeDelete (Node, TRUE);
|
||||
Node->Handle = NULL;
|
||||
} else if (ShellStatus == SHELL_ABORTED) {
|
||||
return EFI_ABORTED;
|
||||
@ -393,29 +409,31 @@ MoveBetweenFileSystems(
|
||||
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
|
||||
**/
|
||||
EFI_STATUS
|
||||
CreateFullDestPath(
|
||||
IN CONST CHAR16 **DestPath,
|
||||
OUT CHAR16 **FullDestPath,
|
||||
IN CONST CHAR16 *FileName
|
||||
CreateFullDestPath (
|
||||
IN CONST CHAR16 **DestPath,
|
||||
OUT CHAR16 **FullDestPath,
|
||||
IN CONST CHAR16 *FileName
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
if (FullDestPath == NULL || FileName == NULL || DestPath == NULL || *DestPath == NULL){
|
||||
UINTN Size;
|
||||
|
||||
if ((FullDestPath == NULL) || (FileName == NULL) || (DestPath == NULL) || (*DestPath == NULL)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Size = StrSize(*DestPath) + StrSize(FileName);
|
||||
Size = StrSize (*DestPath) + StrSize (FileName);
|
||||
|
||||
*FullDestPath = AllocateZeroPool(Size);
|
||||
if (*FullDestPath == NULL){
|
||||
*FullDestPath = AllocateZeroPool (Size);
|
||||
if (*FullDestPath == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
StrCpyS(*FullDestPath, Size / sizeof(CHAR16), *DestPath);
|
||||
if ((*FullDestPath)[StrLen(*FullDestPath)-1] != L'\\' && FileName[0] != L'\\') {
|
||||
StrCatS(*FullDestPath, Size / sizeof(CHAR16), L"\\");
|
||||
StrCpyS (*FullDestPath, Size / sizeof (CHAR16), *DestPath);
|
||||
if (((*FullDestPath)[StrLen (*FullDestPath)-1] != L'\\') && (FileName[0] != L'\\')) {
|
||||
StrCatS (*FullDestPath, Size / sizeof (CHAR16), L"\\");
|
||||
}
|
||||
StrCatS(*FullDestPath, Size / sizeof(CHAR16), FileName);
|
||||
|
||||
StrCatS (*FullDestPath, Size / sizeof (CHAR16), FileName);
|
||||
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
@ -431,46 +449,48 @@ CreateFullDestPath(
|
||||
@retval SHELL_OUT_OF_RESOURCES A memory allocation failed.
|
||||
**/
|
||||
EFI_STATUS
|
||||
MoveWithinFileSystems(
|
||||
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;
|
||||
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));
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
CopyMem (NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);
|
||||
if (DestPath[0] != L'\\') {
|
||||
StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), L"\\");
|
||||
StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
|
||||
StrCpyS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), L"\\");
|
||||
StrCatS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), DestPath);
|
||||
} else {
|
||||
StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
|
||||
StrCpyS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), DestPath);
|
||||
}
|
||||
Length = StrLen(NewFileInfo->FileName);
|
||||
|
||||
Length = StrLen (NewFileInfo->FileName);
|
||||
if (Length > 0) {
|
||||
Length--;
|
||||
}
|
||||
|
||||
if (NewFileInfo->FileName[Length] == L'\\') {
|
||||
if (Node->FileName[0] == L'\\') {
|
||||
//
|
||||
@ -478,23 +498,26 @@ MoveWithinFileSystems(
|
||||
//
|
||||
NewFileInfo->FileName[Length] = CHAR_NULL;
|
||||
}
|
||||
StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), Node->FileName);
|
||||
|
||||
StrCatS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), Node->FileName);
|
||||
}
|
||||
NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize(NewFileInfo->FileName);
|
||||
|
||||
NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize (NewFileInfo->FileName);
|
||||
|
||||
//
|
||||
// Perform the move operation
|
||||
//
|
||||
Status = ShellSetFileInfo(Node->Handle, NewFileInfo);
|
||||
Status = ShellSetFileInfo (Node->Handle, NewFileInfo);
|
||||
|
||||
//
|
||||
// Free the info object we used...
|
||||
//
|
||||
FreePool(NewFileInfo);
|
||||
FreePool (NewFileInfo);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
@ -511,49 +534,49 @@ MoveWithinFileSystems(
|
||||
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
|
||||
**/
|
||||
SHELL_STATUS
|
||||
ValidateAndMoveFiles(
|
||||
IN EFI_SHELL_FILE_INFO *FileList,
|
||||
OUT VOID **Resp,
|
||||
IN CONST CHAR16 *DestParameter
|
||||
ValidateAndMoveFiles (
|
||||
IN EFI_SHELL_FILE_INFO *FileList,
|
||||
OUT VOID **Resp,
|
||||
IN CONST CHAR16 *DestParameter
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR16 *HiiOutput;
|
||||
CHAR16 *HiiResultOk;
|
||||
CHAR16 *DestPath;
|
||||
CHAR16 *FullDestPath;
|
||||
CONST CHAR16 *Cwd;
|
||||
CHAR16 *FullCwd;
|
||||
SHELL_STATUS ShellStatus;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
VOID *Response;
|
||||
UINT64 Attr;
|
||||
CHAR16 *CleanFilePathStr;
|
||||
EFI_STATUS Status;
|
||||
CHAR16 *HiiOutput;
|
||||
CHAR16 *HiiResultOk;
|
||||
CHAR16 *DestPath;
|
||||
CHAR16 *FullDestPath;
|
||||
CONST CHAR16 *Cwd;
|
||||
CHAR16 *FullCwd;
|
||||
SHELL_STATUS ShellStatus;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
VOID *Response;
|
||||
UINT64 Attr;
|
||||
CHAR16 *CleanFilePathStr;
|
||||
|
||||
ASSERT(FileList != NULL);
|
||||
ASSERT(DestParameter != NULL);
|
||||
ASSERT (FileList != NULL);
|
||||
ASSERT (DestParameter != NULL);
|
||||
|
||||
DestPath = NULL;
|
||||
FullDestPath = NULL;
|
||||
Cwd = ShellGetCurrentDir(NULL);
|
||||
Response = *Resp;
|
||||
Attr = 0;
|
||||
CleanFilePathStr = NULL;
|
||||
FullCwd = NULL;
|
||||
DestPath = NULL;
|
||||
FullDestPath = NULL;
|
||||
Cwd = ShellGetCurrentDir (NULL);
|
||||
Response = *Resp;
|
||||
Attr = 0;
|
||||
CleanFilePathStr = NULL;
|
||||
FullCwd = NULL;
|
||||
|
||||
if (Cwd != NULL) {
|
||||
FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
|
||||
FullCwd = AllocateZeroPool (StrSize (Cwd) + sizeof (CHAR16));
|
||||
if (FullCwd == NULL) {
|
||||
return SHELL_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);
|
||||
StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");
|
||||
StrCpyS (FullCwd, StrSize (Cwd)/sizeof (CHAR16)+1, Cwd);
|
||||
StrCatS (FullCwd, StrSize (Cwd)/sizeof (CHAR16)+1, L"\\");
|
||||
}
|
||||
}
|
||||
|
||||
Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);
|
||||
if (EFI_ERROR (Status)) {
|
||||
SHELL_FREE_NON_NULL(FullCwd);
|
||||
SHELL_FREE_NON_NULL (FullCwd);
|
||||
if (Status == EFI_OUT_OF_RESOURCES) {
|
||||
return SHELL_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
@ -566,14 +589,15 @@ ValidateAndMoveFiles(
|
||||
//
|
||||
// Get and validate the destination location
|
||||
//
|
||||
ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
|
||||
ShellStatus = GetDestinationLocation (CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
|
||||
FreePool (CleanFilePathStr);
|
||||
|
||||
if (ShellStatus != SHELL_SUCCESS) {
|
||||
SHELL_FREE_NON_NULL (FullCwd);
|
||||
return (ShellStatus);
|
||||
}
|
||||
DestPath = PathCleanUpDirectories(DestPath);
|
||||
|
||||
DestPath = PathCleanUpDirectories (DestPath);
|
||||
if (DestPath == NULL) {
|
||||
FreePool (FullCwd);
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
@ -581,68 +605,71 @@ ValidateAndMoveFiles(
|
||||
|
||||
HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);
|
||||
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
|
||||
if (HiiOutput == NULL || HiiResultOk == NULL) {
|
||||
SHELL_FREE_NON_NULL(DestPath);
|
||||
SHELL_FREE_NON_NULL(HiiOutput);
|
||||
SHELL_FREE_NON_NULL(HiiResultOk);
|
||||
SHELL_FREE_NON_NULL(FullCwd);
|
||||
if ((HiiOutput == NULL) || (HiiResultOk == NULL)) {
|
||||
SHELL_FREE_NON_NULL (DestPath);
|
||||
SHELL_FREE_NON_NULL (HiiOutput);
|
||||
SHELL_FREE_NON_NULL (HiiResultOk);
|
||||
SHELL_FREE_NON_NULL (FullCwd);
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
//
|
||||
// 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()) {
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// These should never be NULL
|
||||
//
|
||||
ASSERT(Node->FileName != NULL);
|
||||
ASSERT(Node->FullName != NULL);
|
||||
ASSERT(Node->Info != NULL);
|
||||
ASSERT (Node->FileName != NULL);
|
||||
ASSERT (Node->FullName != NULL);
|
||||
ASSERT (Node->Info != NULL);
|
||||
|
||||
//
|
||||
// skip the directory traversing stuff...
|
||||
//
|
||||
if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
|
||||
if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL(FullDestPath);
|
||||
SHELL_FREE_NON_NULL (FullDestPath);
|
||||
FullDestPath = NULL;
|
||||
if (ShellIsDirectory(DestPath)==EFI_SUCCESS) {
|
||||
CreateFullDestPath((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
|
||||
if (ShellIsDirectory (DestPath) == EFI_SUCCESS) {
|
||||
CreateFullDestPath ((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
|
||||
}
|
||||
|
||||
//
|
||||
// Validate that the move is valid
|
||||
//
|
||||
if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
|
||||
if (!IsValidMove (Node->FullName, FullCwd, (FullDestPath != NULL) ? FullDestPath : DestPath, Node->Info->Attribute, Attr, Node->Status)) {
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
continue;
|
||||
}
|
||||
|
||||
ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath!=NULL? FullDestPath:DestPath);
|
||||
ShellPrintEx (-1, -1, HiiOutput, Node->FullName, FullDestPath != NULL ? FullDestPath : DestPath);
|
||||
|
||||
//
|
||||
// See if destination exists
|
||||
//
|
||||
if (!EFI_ERROR(ShellFileExists(FullDestPath!=NULL? FullDestPath:DestPath))) {
|
||||
if (!EFI_ERROR (ShellFileExists ((FullDestPath != NULL) ? FullDestPath : DestPath))) {
|
||||
if (Response == NULL) {
|
||||
ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
|
||||
ShellPromptForResponseHii (ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
|
||||
}
|
||||
|
||||
if (Response == NULL) {
|
||||
return SHELL_ABORTED;
|
||||
}
|
||||
switch (*(SHELL_PROMPT_RESPONSE*)Response) {
|
||||
|
||||
switch (*(SHELL_PROMPT_RESPONSE *)Response) {
|
||||
case ShellPromptResponseNo:
|
||||
FreePool(Response);
|
||||
FreePool (Response);
|
||||
Response = NULL;
|
||||
continue;
|
||||
case ShellPromptResponseCancel:
|
||||
@ -650,42 +677,44 @@ ValidateAndMoveFiles(
|
||||
//
|
||||
// indicate to stop everything
|
||||
//
|
||||
SHELL_FREE_NON_NULL(FullCwd);
|
||||
SHELL_FREE_NON_NULL (FullCwd);
|
||||
return (SHELL_ABORTED);
|
||||
case ShellPromptResponseAll:
|
||||
*Resp = Response;
|
||||
break;
|
||||
case ShellPromptResponseYes:
|
||||
FreePool(Response);
|
||||
FreePool (Response);
|
||||
Response = NULL;
|
||||
break;
|
||||
default:
|
||||
FreePool(Response);
|
||||
SHELL_FREE_NON_NULL(FullCwd);
|
||||
FreePool (Response);
|
||||
SHELL_FREE_NON_NULL (FullCwd);
|
||||
return SHELL_ABORTED;
|
||||
}
|
||||
Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);
|
||||
|
||||
Status = ShellDeleteFileByName (FullDestPath != NULL ? FullDestPath : DestPath);
|
||||
}
|
||||
|
||||
if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {
|
||||
while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {
|
||||
DestPath[StrLen(DestPath) - 1] = CHAR_NULL;
|
||||
if (IsBetweenFileSystem (Node->FullName, FullCwd, DestPath)) {
|
||||
while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen (DestPath) - 1] == L'\\') {
|
||||
DestPath[StrLen (DestPath) - 1] = CHAR_NULL;
|
||||
}
|
||||
Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);
|
||||
|
||||
Status = MoveBetweenFileSystems (Node, FullDestPath != NULL ? FullDestPath : DestPath, &Response);
|
||||
} else {
|
||||
Status = MoveWithinFileSystems(Node, DestPath, &Response);
|
||||
Status = MoveWithinFileSystems (Node, DestPath, &Response);
|
||||
//
|
||||
// Display error status
|
||||
//
|
||||
if (EFI_ERROR(Status)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check our result
|
||||
//
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
if (Status == EFI_SECURITY_VIOLATION) {
|
||||
ShellStatus = SHELL_SECURITY_VIOLATION;
|
||||
@ -699,16 +728,15 @@ ValidateAndMoveFiles(
|
||||
ShellStatus = SHELL_ACCESS_DENIED;
|
||||
}
|
||||
} else {
|
||||
ShellPrintEx(-1, -1, L"%s", HiiResultOk);
|
||||
ShellPrintEx (-1, -1, L"%s", HiiResultOk);
|
||||
}
|
||||
|
||||
} // main for loop
|
||||
|
||||
SHELL_FREE_NON_NULL(FullDestPath);
|
||||
SHELL_FREE_NON_NULL(DestPath);
|
||||
SHELL_FREE_NON_NULL(HiiOutput);
|
||||
SHELL_FREE_NON_NULL(HiiResultOk);
|
||||
SHELL_FREE_NON_NULL(FullCwd);
|
||||
SHELL_FREE_NON_NULL (FullDestPath);
|
||||
SHELL_FREE_NON_NULL (DestPath);
|
||||
SHELL_FREE_NON_NULL (HiiOutput);
|
||||
SHELL_FREE_NON_NULL (HiiResultOk);
|
||||
SHELL_FREE_NON_NULL (FullCwd);
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
@ -725,76 +753,76 @@ ShellCommandRunMv (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
CHAR16 *Cwd;
|
||||
UINTN CwdSize;
|
||||
SHELL_STATUS ShellStatus;
|
||||
UINTN ParamCount;
|
||||
UINTN LoopCounter;
|
||||
EFI_SHELL_FILE_INFO *FileList;
|
||||
VOID *Response;
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
CHAR16 *Cwd;
|
||||
UINTN CwdSize;
|
||||
SHELL_STATUS ShellStatus;
|
||||
UINTN ParamCount;
|
||||
UINTN LoopCounter;
|
||||
EFI_SHELL_FILE_INFO *FileList;
|
||||
VOID *Response;
|
||||
|
||||
ProblemParam = NULL;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
ParamCount = 0;
|
||||
FileList = NULL;
|
||||
Response = NULL;
|
||||
ProblemParam = NULL;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
ParamCount = 0;
|
||||
FileList = NULL;
|
||||
Response = NULL;
|
||||
|
||||
//
|
||||
// initialize the shell lib (we must be in non-auto-init...)
|
||||
//
|
||||
Status = ShellInitialize();
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
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) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);
|
||||
FreePool(ProblemParam);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// check for "-?"
|
||||
//
|
||||
if (ShellCommandLineGetFlag(Package, L"-?")) {
|
||||
ASSERT(FALSE);
|
||||
if (ShellCommandLineGetFlag (Package, L"-?")) {
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
switch (ParamCount = ShellCommandLineGetCount(Package)) {
|
||||
switch (ParamCount = ShellCommandLineGetCount (Package)) {
|
||||
case 0:
|
||||
case 1:
|
||||
//
|
||||
// we have insufficient parameters
|
||||
//
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
break;
|
||||
case 2:
|
||||
//
|
||||
// must have valid CWD for single parameter...
|
||||
//
|
||||
if (ShellGetCurrentDir(NULL) == NULL){
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");
|
||||
if (ShellGetCurrentDir (NULL) == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");
|
||||
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)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1));
|
||||
Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
||||
if ((FileList == NULL) || IsListEmpty (&FileList->Link) || EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue (Package, 1));
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
} else {
|
||||
} else {
|
||||
//
|
||||
// ValidateAndMoveFiles will report errors to the screen itself
|
||||
//
|
||||
CwdSize = StrSize(ShellGetCurrentDir(NULL)) + sizeof(CHAR16);
|
||||
Cwd = AllocateZeroPool(CwdSize);
|
||||
CwdSize = StrSize (ShellGetCurrentDir (NULL)) + sizeof (CHAR16);
|
||||
Cwd = AllocateZeroPool (CwdSize);
|
||||
if (Cwd == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"mv");
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
@ -809,39 +837,42 @@ ShellCommandRunMv (
|
||||
|
||||
break;
|
||||
default:
|
||||
///@todo make sure this works with error half way through and continues...
|
||||
for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount ; LoopCounter++) {
|
||||
if (ShellGetExecutionBreakFlag()) {
|
||||
/// @todo make sure this works with error half way through and continues...
|
||||
for (ParamCount--, LoopCounter = 1; LoopCounter < ParamCount; LoopCounter++) {
|
||||
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)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, LoopCounter));
|
||||
|
||||
Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
||||
if ((FileList == NULL) || IsListEmpty (&FileList->Link) || EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue (Package, LoopCounter));
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
} else {
|
||||
} else {
|
||||
//
|
||||
// ValidateAndMoveFiles will report errors to the screen itself
|
||||
// Only change ShellStatus if it's sucessful
|
||||
//
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
|
||||
ShellStatus = ValidateAndMoveFiles (FileList, &Response, ShellCommandLineGetRawValue (Package, ParamCount));
|
||||
} else {
|
||||
ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
|
||||
ValidateAndMoveFiles (FileList, &Response, ShellCommandLineGetRawValue (Package, ParamCount));
|
||||
}
|
||||
}
|
||||
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
|
||||
Status = ShellCloseFileMetaArg(&FileList);
|
||||
if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
|
||||
|
||||
if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
|
||||
Status = ShellCloseFileMetaArg (&FileList);
|
||||
if (EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS)) {
|
||||
ShellStatus = SHELL_ACCESS_DENIED;
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1), ShellStatus|MAX_BIT);
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue (Package, 1), ShellStatus|MAX_BIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} // switch on parameter count
|
||||
|
||||
if (FileList != NULL) {
|
||||
ShellCloseFileMetaArg(&FileList);
|
||||
ShellCloseFileMetaArg (&FileList);
|
||||
}
|
||||
|
||||
//
|
||||
@ -850,9 +881,9 @@ ShellCommandRunMv (
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL(Response);
|
||||
SHELL_FREE_NON_NULL (Response);
|
||||
|
||||
if (ShellGetExecutionBreakFlag()) {
|
||||
if (ShellGetExecutionBreakFlag ()) {
|
||||
return (SHELL_ABORTED);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user