CHAR16 *HiiResultOk;\r
CONST EFI_SHELL_FILE_INFO *Node;\r
SHELL_STATUS ShellStatus;\r
+ EFI_STATUS Status;\r
CHAR16 *DestPath;\r
VOID *Response;\r
UINTN PathSize;\r
CONST CHAR16 *Cwd;\r
UINTN NewSize;\r
+ CHAR16 *CleanFilePathStr;\r
\r
if (Resp == NULL) {\r
Response = NULL;\r
ASSERT(FileList != NULL);\r
ASSERT(DestDir != NULL);\r
\r
+ \r
+ Status = ShellLevel2StripQuotes (DestDir, &CleanFilePathStr);\r
+ if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_OUT_OF_RESOURCES) {\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ } else {\r
+ return SHELL_INVALID_PARAMETER;\r
+ }\r
+ } \r
+\r
//\r
// If we are trying to copy multiple files... make sure we got a directory for the target...\r
//\r
- if (EFI_ERROR(ShellIsDirectory(DestDir)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {\r
+ if (EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {\r
//\r
// Error for destination not a directory\r
//\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, DestDir);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, CleanFilePathStr);\r
+ FreePool (CleanFilePathStr);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)\r
continue;\r
}\r
\r
- NewSize = StrSize(DestDir);\r
+ NewSize = StrSize(CleanFilePathStr);\r
NewSize += StrSize(Node->FullName);\r
NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);\r
if (NewSize > PathSize) {\r
//\r
if (!RecursiveMode && !EFI_ERROR(ShellIsDirectory(Node->FullName))) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle);\r
+ FreePool (CleanFilePathStr);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
\r
//\r
// make sure got dest as dir if needed\r
//\r
- if (!EFI_ERROR(ShellIsDirectory(Node->FullName)) && EFI_ERROR(ShellIsDirectory(DestDir))) {\r
+ if (!EFI_ERROR(ShellIsDirectory(Node->FullName)) && EFI_ERROR(ShellIsDirectory(CleanFilePathStr))) {\r
//\r
// Error for destination not a directory\r
//\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, DestDir);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, CleanFilePathStr);\r
+ FreePool (CleanFilePathStr);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
}\r
SHELL_FREE_NON_NULL(DestPath);\r
SHELL_FREE_NON_NULL(HiiOutput);\r
SHELL_FREE_NON_NULL(HiiResultOk);\r
+ FreePool (CleanFilePathStr);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
\r
}\r
\r
if (FileList->Link.ForwardLink == FileList->Link.BackLink // 1 item\r
- && EFI_ERROR(ShellIsDirectory(DestDir)) // not an existing directory\r
+ && EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) // not an existing directory\r
) {\r
- if (StrStr(DestDir, L":") == NULL) {\r
+ if (StrStr(CleanFilePathStr, L":") == NULL) {\r
//\r
// simple copy of a single file\r
//\r
if (Cwd != NULL) {\r
StrnCpy(DestPath, Cwd, PathSize/sizeof(CHAR16)-1);\r
} else {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, DestDir);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, CleanFilePathStr);\r
+ FreePool (CleanFilePathStr);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
- if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {\r
+ if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') {\r
StrnCat(DestPath, L"\\", PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestDir[0] == L'\\') {\r
+ } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') {\r
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;\r
}\r
- StrnCat(DestPath, DestDir, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
+ StrnCat(DestPath, CleanFilePathStr, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
} else {\r
- StrnCpy(DestPath, DestDir, PathSize/sizeof(CHAR16) -1);\r
+ StrnCpy(DestPath, CleanFilePathStr, PathSize/sizeof(CHAR16) -1);\r
}\r
} else {\r
//\r
//\r
// Check for leading slash\r
//\r
- if (DestDir[0] == L'\\') {\r
+ if (CleanFilePathStr[0] == L'\\') {\r
//\r
// Copy to the root of CWD\r
//\r
if (Cwd != NULL) {\r
StrnCpy(DestPath, Cwd, PathSize/sizeof(CHAR16) -1);\r
} else {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, DestDir);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, CleanFilePathStr);\r
+ FreePool(CleanFilePathStr);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
while (PathRemoveLastItem(DestPath));\r
- StrnCat(DestPath, DestDir+1, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
+ StrnCat(DestPath, CleanFilePathStr+1, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
StrnCat(DestPath, Node->FileName, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
- } else if (StrStr(DestDir, L":") == NULL) {\r
+ } else if (StrStr(CleanFilePathStr, L":") == NULL) {\r
if (Cwd != NULL) {\r
StrnCpy(DestPath, Cwd, PathSize/sizeof(CHAR16) -1);\r
} else {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, DestDir);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, CleanFilePathStr);\r
+ FreePool(CleanFilePathStr);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
- if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {\r
+ if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') {\r
StrnCat(DestPath, L"\\", PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestDir[0] == L'\\') {\r
+ } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') {\r
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;\r
}\r
- StrnCat(DestPath, DestDir, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
- if (DestDir[StrLen(DestDir)-1] != L'\\' && Node->FileName[0] != L'\\') {\r
+ StrnCat(DestPath, CleanFilePathStr, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
+ if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') {\r
StrnCat(DestPath, L"\\", PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
- } else if (DestDir[StrLen(DestDir)-1] == L'\\' && Node->FileName[0] == L'\\') {\r
+ } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') {\r
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;\r
}\r
StrnCat(DestPath, Node->FileName, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
\r
} else {\r
- StrnCpy(DestPath, DestDir, PathSize/sizeof(CHAR16) -1);\r
- if (DestDir[StrLen(DestDir)-1] != L'\\' && Node->FileName[0] != L'\\') {\r
+ StrnCpy(DestPath, CleanFilePathStr, PathSize/sizeof(CHAR16) -1);\r
+ if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') {\r
StrnCat(DestPath, L"\\", PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
- } else if (DestDir[StrLen(DestDir)-1] == L'\\' && Node->FileName[0] == L'\\') {\r
- ((CHAR16*)DestDir)[StrLen(DestDir)-1] = CHAR_NULL;\r
+ } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') {\r
+ ((CHAR16*)CleanFilePathStr)[StrLen(CleanFilePathStr)-1] = CHAR_NULL;\r
}\r
StrnCat(DestPath, Node->FileName, PathSize/sizeof(CHAR16) - StrLen(DestPath) -1);\r
}\r
}\r
-\r
+ FreePool (CleanFilePathStr);\r
//\r
// Make sure the path exists\r
//\r
{\r
EFI_STATUS Status;\r
LIST_ENTRY mOldStyleFileList;\r
+ CHAR16 *CleanFilePathStr;\r
\r
//\r
// ASSERT that Arg and ListHead are not NULL\r
ASSERT(Arg != NULL);\r
ASSERT(ListHead != NULL);\r
\r
+ Status = InternalShellStripQuotes (Arg, &CleanFilePathStr);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
//\r
// Check for UEFI Shell 2.0 protocols\r
//\r
if (*ListHead == NULL) {\r
*ListHead = (EFI_SHELL_FILE_INFO*)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
if (*ListHead == NULL) {\r
+ FreePool(CleanFilePathStr);\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
InitializeListHead(&((*ListHead)->Link));\r
}\r
- Status = gEfiShellProtocol->OpenFileList(Arg,\r
+ Status = gEfiShellProtocol->OpenFileList(CleanFilePathStr,\r
OpenMode,\r
ListHead);\r
if (EFI_ERROR(Status)) {\r
}\r
if (*ListHead != NULL && IsListEmpty(&(*ListHead)->Link)) {\r
FreePool(*ListHead);\r
+ FreePool(CleanFilePathStr);\r
*ListHead = NULL;\r
return (EFI_NOT_FOUND);\r
}\r
+ FreePool(CleanFilePathStr);\r
return (Status);\r
}\r
\r
//\r
// Get the EFI Shell list of files\r
//\r
- Status = mEfiShellEnvironment2->FileMetaArg(Arg, &mOldStyleFileList);\r
+ Status = mEfiShellEnvironment2->FileMetaArg(CleanFilePathStr, &mOldStyleFileList);\r
if (EFI_ERROR(Status)) {\r
*ListHead = NULL;\r
+ FreePool(CleanFilePathStr);\r
return (Status);\r
}\r
\r
if (*ListHead == NULL) {\r
*ListHead = (EFI_SHELL_FILE_INFO *)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
if (*ListHead == NULL) {\r
+ FreePool(CleanFilePathStr);\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
InitializeListHead(&((*ListHead)->Link));\r
*ListHead = NULL;\r
Status = EFI_NOT_FOUND;\r
}\r
+ FreePool(CleanFilePathStr);\r
return (Status);\r
}\r
\r
+ FreePool(CleanFilePathStr);\r
return (EFI_UNSUPPORTED);\r
}\r
/**\r
return(Status);\r
\r
}\r
+\r
+/**\r
+ Cleans off all the quotes in the string.\r
+\r
+ @param[in] OriginalString pointer to the string to be cleaned.\r
+ @param[out] CleanString The new string with all quotes removed. \r
+ Memory allocated in the function and free \r
+ by caller.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalShellStripQuotes (\r
+ IN CONST CHAR16 *OriginalString,\r
+ OUT CHAR16 **CleanString\r
+ )\r
+{\r
+ CHAR16 *Walker;\r
+ \r
+ if (OriginalString == NULL || CleanString == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);\r
+ if (*CleanString == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {\r
+ if (*Walker == L'\"') {\r
+ CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r