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
This commit is contained in:
@ -510,6 +510,7 @@ FileInterfaceStdInRead(
|
||||
Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);
|
||||
if (Cwd != NULL) {
|
||||
StrnCpyS(TabStr, (*BufferSize)/sizeof(CHAR16), Cwd, (*BufferSize)/sizeof(CHAR16) - 1);
|
||||
StrCatS(TabStr, (*BufferSize)/sizeof(CHAR16), L"\\");
|
||||
if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {
|
||||
TabStr[StrLen(TabStr)-1] = CHAR_NULL;
|
||||
}
|
||||
|
Binary file not shown.
@ -532,12 +532,13 @@ EfiShellGetDevicePathFromFilePath(
|
||||
if (Cwd == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
Size = StrSize(Cwd) + StrSize(Path) - sizeof(CHAR16);
|
||||
Size = StrSize(Cwd) + StrSize(Path);
|
||||
NewPath = AllocateZeroPool(Size);
|
||||
if (NewPath == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
StrCpyS(NewPath, Size/sizeof(CHAR16), Cwd);
|
||||
StrCatS(NewPath, Size/sizeof(CHAR16), L"\\");
|
||||
if (*Path == L'\\') {
|
||||
Path++;
|
||||
while (PathRemoveLastItem(NewPath)) ;
|
||||
@ -2495,6 +2496,7 @@ EfiShellOpenFileList(
|
||||
CurDir = EfiShellGetCurDir(NULL);
|
||||
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
|
||||
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
|
||||
StrnCatGrow(&Path2, &Path2Size, L"\\", 0);
|
||||
if (*Path == L'\\') {
|
||||
Path++;
|
||||
while (PathRemoveLastItem(Path2)) ;
|
||||
@ -2796,6 +2798,8 @@ EfiShellSetEnv(
|
||||
FileSystemMapping is not NULL, it returns the current directory associated with the
|
||||
FileSystemMapping. In both cases, the returned name includes the file system
|
||||
mapping (i.e. fs0:\current-dir).
|
||||
|
||||
Note that the current directory string should exclude the tailing backslash character.
|
||||
|
||||
@param FileSystemMapping A pointer to the file system mapping. If NULL,
|
||||
then the current working directory is returned.
|
||||
@ -2852,6 +2856,8 @@ EfiShellGetCurDir(
|
||||
If the current working directory or the current working file system is changed then the
|
||||
%cwd% environment variable will be updated
|
||||
|
||||
Note that the current directory string should exclude the tailing backslash character.
|
||||
|
||||
@param FileSystem A pointer to the file system's mapped name. If NULL, then the current working
|
||||
directory is changed.
|
||||
@param Dir Points to the NULL-terminated directory on the device specified by FileSystem.
|
||||
@ -2939,9 +2945,11 @@ EfiShellSetCurDir(
|
||||
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
|
||||
}
|
||||
if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
|
||||
if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
|
||||
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
||||
if (MapListItem->CurrentDirectoryPath != NULL) {
|
||||
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//
|
||||
@ -2973,9 +2981,9 @@ EfiShellSetCurDir(
|
||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
||||
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
|
||||
if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {
|
||||
if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') {
|
||||
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
||||
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user