diff options
author | Qiu Shumin <shumin.qiu@intel.com> | 2015-10-23 02:03:20 +0000 |
---|---|---|
committer | shenshushi <shenshushi@Edk2> | 2015-10-23 02:03:20 +0000 |
commit | fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a (patch) | |
tree | 62be65e0eb87049beeb36b8ac95c2f127ce13c72 /ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | |
parent | a7e173b07a1ef336fc8d753cf85ae8473e92365a (diff) | |
download | edk2-platforms-fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a.tar.xz |
ShellPkg: Follow spec to remove the last '\' char in return name of GetCurDir().
In Shell spec 2.1 the return name of EFI_SHELL_PROTOCOL.GetCurDir() is defined as 'fs0:\current-dir' while in current implementation it's 'fs0:\current-dir\'.
To follow spec the patch removed the redundant '\' char.
Since it has been broken for a long time, some codes may depend on the broken behavior.
After this change 'EFI_SHELL_PROTOCOL.GetCurDir()' and 'UefiShellLib.ShellGetCurrentDir()'
will return a current directory string without tailing '\' (fs0:\current-dir), the value of Shell environment variable 'cwd' will become 'fs0:\current-dir' as well.
This patch has updated all the code in EDKII to make them depend on the new behavior.
Developers should check whether 'GetCurDir()' and 'ShellGetCurrentDir' are used in their source code.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18653 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c')
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c index deff42e049..5cfbc9064f 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c @@ -360,7 +360,7 @@ ValidateAndCopyFiles( NewSize = StrSize(CleanFilePathStr);
NewSize += StrSize(Node->FullName);
- NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);
+ NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16));
if (NewSize > PathSize) {
PathSize = NewSize;
}
@@ -428,6 +428,7 @@ ValidateAndCopyFiles( //
if (Cwd != NULL) {
StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd);
+ StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool (CleanFilePathStr);
@@ -456,6 +457,7 @@ ValidateAndCopyFiles( //
if (Cwd != NULL) {
StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
+ StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool(CleanFilePathStr);
@@ -467,6 +469,7 @@ ValidateAndCopyFiles( } else if (StrStr(CleanFilePathStr, L":") == NULL) {
if (Cwd != NULL) {
StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
+ StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool(CleanFilePathStr);
@@ -644,6 +647,7 @@ ShellCommandRunCp ( BOOLEAN SilentMode;
BOOLEAN RecursiveMode;
CONST CHAR16 *Cwd;
+ CHAR16 *FullCwd;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
@@ -712,7 +716,11 @@ ShellCommandRunCp ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));
ShellStatus = SHELL_NOT_FOUND;
} else {
- ShellStatus = ProcessValidateAndCopyFiles(FileList, Cwd, SilentMode, RecursiveMode);
+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
+ ASSERT (FullCwd != NULL);
+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);
+ ShellStatus = ProcessValidateAndCopyFiles(FileList, FullCwd, SilentMode, RecursiveMode);
+ FreePool(FullCwd);
}
}
|