diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-11-20 21:13:41 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-11-20 21:13:41 +0000 |
commit | 36a9d6726135a07601999f5394185f6333127109 (patch) | |
tree | 17437c3f0d508cd4c9dbb8a4b29fe709c57f39ba /ShellPkg/Library | |
parent | a31bd33cf8089c0b0219a41afb06cf9b462a0ee3 (diff) | |
download | edk2-platforms-36a9d6726135a07601999f5394185f6333127109.tar.xz |
build break fix and new function
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9461 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 88 |
1 files changed, 86 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index e52d1e7627..b1128ffc14 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -1489,12 +1489,15 @@ ShellFindFilePath ( CHAR16 *RetVal;
CHAR16 *TestPath;
CONST CHAR16 *Walker;
+ UINTN Size;
RetVal = NULL;
Path = ShellGetEnvironmentVariable(L"cwd");
if (Path != NULL) {
- TestPath = AllocateZeroPool((StrSize(Path) + StrSize(FileName)));
+ Size = StrSize(Path);
+ Size += StrSize(FileName);
+ TestPath = AllocateZeroPool(Size);
StrCpy(TestPath, Path);
StrCat(TestPath, FileName);
Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);
@@ -1508,7 +1511,9 @@ ShellFindFilePath ( }
Path = ShellGetEnvironmentVariable(L"path");
if (Path != NULL) {
- TestPath = AllocateZeroPool((StrSize(Path)+StrSize(FileName)));
+ Size = StrSize(Path);
+ Size += StrSize(FileName);
+ TestPath = AllocateZeroPool(Size);
Walker = (CHAR16*)Path;
do {
CopyMem(TestPath, Walker, StrSize(Walker));
@@ -2130,6 +2135,52 @@ ShellCommandLineGetCount( }
/**
+ Determins if a parameter is duplicated.
+
+ If Param is not NULL then it will point to a callee allocated string buffer
+ with the parameter value if a duplicate is found.
+
+ If CheckPackage is NULL, then ASSERT.
+
+ @param[in] CheckPackage The package of parsed command line arguments.
+ @param[out] Param Upon finding one, a pointer to the duplicated parameter.
+
+ @retval EFI_SUCCESS No parameters were duplicated.
+ @retval EFI_DEVICE_ERROR A duplicate was found.
+ **/
+EFI_STATUS
+EFIAPI
+ShellCommandLineCheckDuplicate (
+ IN CONST LIST_ENTRY *CheckPackage,
+ OUT CHAR16 **Param
+ )
+{
+ LIST_ENTRY *Node1;
+ LIST_ENTRY *Node2;
+
+ ASSERT(CheckPackage != NULL);
+
+ for ( Node1 = GetFirstNode(CheckPackage)
+ ; !IsNull (CheckPackage, Node1)
+ ; Node1 = GetNextNode(CheckPackage, Node1)
+ ){
+ for ( Node2 = GetNextNode(CheckPackage, Node1)
+ ; !IsNull (CheckPackage, Node2)
+ ; Node2 = GetNextNode(CheckPackage, Node2)
+ ){
+ if (StrCmp(((SHELL_PARAM_PACKAGE*)Node1)->Name, ((SHELL_PARAM_PACKAGE*)Node2)->Name) == 0) {
+ if (Param != NULL) {
+ *Param = NULL;
+ *Param = StrnCatGrow(Param, NULL, ((SHELL_PARAM_PACKAGE*)Node1)->Name, 0);
+ }
+ return (EFI_DEVICE_ERROR);
+ }
+ }
+ }
+ return (EFI_SUCCESS);
+}
+
+/**
This is a find and replace function. it will return the NewString as a copy of
SourceString with each instance of FindTarget replaced with ReplaceWith.
@@ -2460,6 +2511,39 @@ ShellIsDirectory( }
/**
+ Function to determine if a given filename represents a file.
+
+ @param[in] Name Path to file to test.
+
+ @retval EFI_SUCCESS The Path represents a file.
+ @retval EFI_NOT_FOUND The Path does not represent a file.
+ @retval other The path failed to open.
+**/
+EFI_STATUS
+EFIAPI
+ShellIsFile(
+ IN CONST CHAR16 *Name
+ )
+{
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE Handle;
+
+ Handle = NULL;
+
+ Status = ShellOpenFileByName(Name, &Handle, EFI_FILE_MODE_READ, 0);
+ if (EFI_ERROR(Status)) {
+ return (Status);
+ }
+
+ if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {
+ ShellCloseFile(&Handle);
+ return (EFI_SUCCESS);
+ }
+ ShellCloseFile(&Handle);
+ return (EFI_NOT_FOUND);
+}
+
+/**
Function to determine whether a string is decimal or hex representation of a number
and return the number converted from the string.
|