summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-20 21:01:34 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-20 21:01:34 +0000
commit1fc3749dad42e8d5caebf6e0e0327b713b6adaeb (patch)
treea0d6762cad812852bbd416bdb8603bbdd4087fc3
parente291948ce0b6f3439f83da5861ddd337421dc5e4 (diff)
downloadedk2-1fc3749dad42e8d5caebf6e0e0327b713b6adaeb.zip
edk2-1fc3749dad42e8d5caebf6e0e0327b713b6adaeb.tar.gz
edk2-1fc3749dad42e8d5caebf6e0e0327b713b6adaeb.tar.bz2
ShellPkg: fix support for "\" (or "\.") meaning root of drive.
Cp command fixed to allow for copying single or multiple files to the root of the drive with destination directory \. Cd command fixed to allow for changing CWD to the root of the drive with destination directory \. signed-off-by: jcarsey reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12392 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--ShellPkg/Library/BasePathLib/BasePathLib.c2
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c24
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c14
3 files changed, 28 insertions, 12 deletions
diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.c b/ShellPkg/Library/BasePathLib/BasePathLib.c
index 77d5866..2166c9d 100644
--- a/ShellPkg/Library/BasePathLib/BasePathLib.c
+++ b/ShellPkg/Library/BasePathLib/BasePathLib.c
@@ -112,7 +112,7 @@ PathCleanUpDirectories(
CopyMem(Path+StrLen(Path), TempString, TempSize);
}
if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) {
- *TempString = CHAR_NULL;
+ *(TempString + 1) = CHAR_NULL;
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
index 82d1c39..c753702 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
@@ -37,6 +37,7 @@ ShellCommandRunCd (
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE Handle;
CONST CHAR16 *Param1;
+ CHAR16 *Param1Copy;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
@@ -94,11 +95,13 @@ ShellCommandRunCd (
ShellStatus = SHELL_NOT_FOUND;
}
} else {
- if (StrCmp(Param1, L".") == 0) {
+ Param1Copy = CatSPrint(NULL, L"%s", Param1, NULL);
+ Param1Copy = PathCleanUpDirectories(Param1Copy);
+ if (StrCmp(Param1Copy, L".") == 0) {
//
// nothing to do... change to current directory
//
- } else if (StrCmp(Param1, L"..") == 0) {
+ } else if (StrCmp(Param1Copy, L"..") == 0) {
//
// Change up one directory...
//
@@ -120,7 +123,7 @@ ShellCommandRunCd (
ShellStatus = SHELL_NOT_FOUND;
}
}
- } else if (StrCmp(Param1, L"\\") == 0) {
+ } else if (StrCmp(Param1Copy, L"\\") == 0) {
//
// Move to root of current drive
//
@@ -142,18 +145,18 @@ ShellCommandRunCd (
ShellStatus = SHELL_NOT_FOUND;
}
}
- } else if (StrStr(Param1, L":") == NULL) {
+ } else if (StrStr(Param1Copy, L":") == NULL) {
if (ShellGetCurrentDir(NULL) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
ShellStatus = SHELL_NOT_FOUND;
} else {
ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));
Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL), 0);
- if (*Param1 == L'\\') {
+ if (*Param1Copy == L'\\') {
while (PathRemoveLastItem(Drive)) ;
- Drive = StrnCatGrow(&Drive, &DriveSize, Param1+1, 0);
+ Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy+1, 0);
} else {
- Drive = StrnCatGrow(&Drive, &DriveSize, Param1, 0);
+ Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy, 0);
}
//
// Verify that this is a valid directory
@@ -185,12 +188,12 @@ ShellCommandRunCd (
//
// change directory on other drive letter
//
- Drive = AllocateZeroPool(StrSize(Param1));
+ Drive = AllocateZeroPool(StrSize(Param1Copy));
if (Drive == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
- Drive = StrCpy(Drive, Param1);
+ Drive = StrCpy(Drive, Param1Copy);
Path = StrStr(Drive, L":");
ASSERT(Path != NULL);
if (*(Path+1) == CHAR_NULL) {
@@ -210,11 +213,12 @@ ShellCommandRunCd (
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
Status = SHELL_NOT_FOUND;
} else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1Copy);
Status = SHELL_NOT_FOUND;
}
}
}
+ FreePool(Param1Copy);
}
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
index 08f5514..00b51b4 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
@@ -359,7 +359,19 @@ ValidateAndCopyFiles(
//
// we have multiple files or a directory in the DestDir
//
- if (StrStr(DestDir, L":") == NULL) {
+
+ //
+ // Check for leading slash
+ //
+ if (DestDir[0] == L'\\') {
+ //
+ // Copy to the root of CWD
+ //
+ StrCpy(DestPath, Cwd);
+ while (PathRemoveLastItem(DestPath));
+ StrCat(DestPath, DestDir+1);
+ StrCat(DestPath, Node->FileName);
+ } else if (StrStr(DestDir, L":") == NULL) {
StrCpy(DestPath, Cwd);
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
StrCat(DestPath, L"\\");