This refactors 3 functions out of ShellCommandLib and puts them into a new library (but as 2 functions instead of 3). This allows for users outside of the shell itself to have access to these functions.

1) Remove the 3 functions out of the shell's internal library (ShellCommandLib)
2) Add a new library class (PathLib)
3) Add an instance of this class (BasePathLib)
4) Change all internal shell callers to use this new library class.

signed-off-by: jcarsey
reviewed-by: jljusten

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11936 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey
2011-06-30 22:58:53 +00:00
parent f1518f6970
commit ab94587a7d
21 changed files with 245 additions and 173 deletions

View File

@@ -522,7 +522,7 @@ FileInterfaceStdInRead(
}
StrCat(TabStr, L"*");
FoundFileList = NULL;
// TabStr = CleanPath(TabStr);
// TabStr = PathCleanUpDirectories(TabStr);
Status = ShellInfoObject.NewEfiShellProtocol->FindFiles(TabStr, &FoundFileList);
for ( TempStr = CurrentString
; *TempStr == L' '

View File

@@ -859,7 +859,7 @@ DoStartupScript(
*TempSpot = CHAR_NULL;
}
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, ((FILEPATH_DEVICE_PATH*)FilePath)->PathName, 0);
ChopLastSlash(FileStringPath);
PathRemoveLastItem(FileStringPath);
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, mStartupScript, 0);
Status = ShellInfoObject.NewEfiShellProtocol->OpenFileByName(FileStringPath, &FileHandle, EFI_FILE_MODE_READ);
FreePool(FileStringPath);

View File

@@ -44,6 +44,7 @@
#include <Library/HiiLib.h>
#include <Library/PrintLib.h>
#include <Library/HandleParsingLib.h>
#include <Library/PathLib.h>
#include "ShellParametersProtocol.h"
#include "ShellProtocol.h"

View File

@@ -1,7 +1,7 @@
## @file
# This is the shell application
#
# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -69,6 +69,7 @@
HiiLib
SortLib
HandleParsingLib
PathLib
[Guids]
gShellVariableGuid # ALWAYS_CONSUMED

View File

@@ -529,7 +529,7 @@ EfiShellGetDevicePathFromFilePath(
StrCpy(NewPath, Cwd);
if (*Path == L'\\') {
Path++;
while (ChopLastSlash(NewPath)) ;
while (PathRemoveLastItem(NewPath)) ;
}
StrCat(NewPath, Path);
DevicePathForReturn = EfiShellGetDevicePathFromFilePath(NewPath);
@@ -2232,7 +2232,7 @@ EfiShellFindFiles(
}
StrCpy(PatternCopy, FilePattern);
PatternCopy = CleanPath(PatternCopy);
PatternCopy = PathCleanUpDirectories(PatternCopy);
Count = StrStr(PatternCopy, L":") - PatternCopy;
Count += 2;
@@ -2293,7 +2293,7 @@ EfiShellOpenFileList(
CONST CHAR16 *CurDir;
BOOLEAN Found;
ShellCommandCleanPath(Path);
PathCleanUpDirectories(Path);
Path2Size = 0;
Path2 = NULL;
@@ -2315,7 +2315,7 @@ EfiShellOpenFileList(
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
if (*Path == L'\\') {
Path++;
while (ChopLastSlash(Path2)) ;
while (PathRemoveLastItem(Path2)) ;
}
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
StrnCatGrow(&Path2, &Path2Size, Path, 0);
@@ -2324,7 +2324,7 @@ EfiShellOpenFileList(
StrnCatGrow(&Path2, NULL, Path, 0);
}
CleanPath (Path2);
PathCleanUpDirectories (Path2);
//
// do the search
@@ -2677,7 +2677,7 @@ EfiShellSetCurDir(
DirectoryName = StrnCatGrow(&DirectoryName, NULL, Dir, 0);
ASSERT(DirectoryName != NULL);
CleanPath(DirectoryName);
PathCleanUpDirectories(DirectoryName);
if (FileSystem == NULL) {
//