SHELL_STATUS ShellStatus;\r
SHELL_FILE_HANDLE Handle;\r
CONST CHAR16 *Param1;\r
+ CHAR16 *Param1Copy;\r
\r
ProblemParam = NULL;\r
ShellStatus = SHELL_SUCCESS;\r
ShellStatus = SHELL_NOT_FOUND;\r
}\r
} else {\r
- if (StrCmp(Param1, L".") == 0) {\r
+ Param1Copy = CatSPrint(NULL, L"%s", Param1, NULL);\r
+ Param1Copy = PathCleanUpDirectories(Param1Copy);\r
+ if (StrCmp(Param1Copy, L".") == 0) {\r
//\r
// nothing to do... change to current directory\r
//\r
- } else if (StrCmp(Param1, L"..") == 0) {\r
+ } else if (StrCmp(Param1Copy, L"..") == 0) {\r
//\r
// Change up one directory...\r
//\r
ShellStatus = SHELL_NOT_FOUND;\r
}\r
}\r
- } else if (StrCmp(Param1, L"\\") == 0) {\r
+ } else if (StrCmp(Param1Copy, L"\\") == 0) {\r
//\r
// Move to root of current drive\r
//\r
ShellStatus = SHELL_NOT_FOUND;\r
}\r
}\r
- } else if (StrStr(Param1, L":") == NULL) {\r
+ } else if (StrStr(Param1Copy, L":") == NULL) {\r
if (ShellGetCurrentDir(NULL) == NULL) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);\r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));\r
Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL), 0);\r
- if (*Param1 == L'\\') {\r
+ if (*Param1Copy == L'\\') {\r
while (PathRemoveLastItem(Drive)) ;\r
- Drive = StrnCatGrow(&Drive, &DriveSize, Param1+1, 0);\r
+ Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy+1, 0);\r
} else {\r
- Drive = StrnCatGrow(&Drive, &DriveSize, Param1, 0);\r
+ Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy, 0);\r
}\r
//\r
// Verify that this is a valid directory\r
//\r
// change directory on other drive letter\r
//\r
- Drive = AllocateZeroPool(StrSize(Param1));\r
+ Drive = AllocateZeroPool(StrSize(Param1Copy));\r
if (Drive == NULL) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);\r
ShellStatus = SHELL_OUT_OF_RESOURCES;\r
} else {\r
- Drive = StrCpy(Drive, Param1);\r
+ Drive = StrCpy(Drive, Param1Copy);\r
Path = StrStr(Drive, L":");\r
ASSERT(Path != NULL);\r
if (*(Path+1) == CHAR_NULL) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);\r
Status = SHELL_NOT_FOUND;\r
} else if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1Copy);\r
Status = SHELL_NOT_FOUND;\r
}\r
}\r
}\r
+ FreePool(Param1Copy);\r
}\r
}\r
\r
//\r
// we have multiple files or a directory in the DestDir\r
//\r
- if (StrStr(DestDir, L":") == NULL) {\r
+ \r
+ //\r
+ // Check for leading slash\r
+ //\r
+ if (DestDir[0] == L'\\') {\r
+ //\r
+ // Copy to the root of CWD\r
+ //\r
+ StrCpy(DestPath, Cwd);\r
+ while (PathRemoveLastItem(DestPath));\r
+ StrCat(DestPath, DestDir+1);\r
+ StrCat(DestPath, Node->FileName);\r
+ } else if (StrStr(DestDir, L":") == NULL) {\r
StrCpy(DestPath, Cwd);\r
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {\r
StrCat(DestPath, L"\\");\r