From ab94587a7d2cd89695f9190420daceae0d2b7446 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Thu, 30 Jun 2011 22:58:53 +0000 Subject: 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 --- .../UefiShellCommandLib/UefiShellCommandLib.c | 106 --------------------- 1 file changed, 106 deletions(-) (limited to 'ShellPkg/Library/UefiShellCommandLib') diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index 82a9e78ed5..28b7dda51e 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -1122,30 +1122,6 @@ ShellCommandCreateInitialMappingsAndPaths( return (EFI_SUCCESS); } -/** - Function to make sure all directory delimeters are backslashes. - - @param[in,out] Path The path to modify. - - @return Path. -**/ -CHAR16* -EFIAPI -ShellCommandCleanPath ( - IN OUT CHAR16 *Path - ) -{ - CHAR16 *Path2; - - for (Path2 = Path ; Path2 != NULL && *Path2 != CHAR_NULL ; Path2++) { - if (*Path2 == L'/') { - *Path2 = L'\\'; - } - } - - return (Path); -} - /** Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*. @@ -1489,85 +1465,3 @@ FreeBufferList ( } } -/** - Chops off last directory or file entry in a path leaving the trailing slash - - @param[in,out] PathToReturn The path to modify. - - @retval FALSE No directory was found to chop off. - @retval TRUE A directory was chopped off. -**/ -BOOLEAN -EFIAPI -ChopLastSlash( - IN OUT CHAR16 *PathToReturn - ) -{ - CHAR16 *Walker; - CHAR16 *LastSlash; - // - // get directory name from path... ('chop' off extra) - // - for ( Walker = PathToReturn, LastSlash = NULL - ; Walker != NULL && *Walker != CHAR_NULL - ; Walker++ - ){ - if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) { - LastSlash = Walker+1; - } - } - if (LastSlash != NULL) { - *LastSlash = CHAR_NULL; - return (TRUE); - } - return (FALSE); -} - -/** - Function to clean up paths. Removes the following items: - single periods in the path (no need for the current directory tag) - double periods in the path and removes a single parent directory. - - This will be done inline and the resultant string may be be 'too big'. - - @param[in] PathToReturn The pointer to the string containing the path. - - @return PathToReturn is always returned. -**/ -CHAR16* -EFIAPI -CleanPath( - IN CHAR16 *PathToReturn - ) -{ - CHAR16 *TempString; - UINTN TempSize; - if (PathToReturn==NULL) { - return(NULL); - } - // - // Fix up the directory name - // - while ((TempString = StrStr(PathToReturn, L"\\..\\")) != NULL) { - *TempString = CHAR_NULL; - TempString += 4; - ChopLastSlash(PathToReturn); - TempSize = StrSize(TempString); - CopyMem(PathToReturn+StrLen(PathToReturn), TempString, TempSize); - } - if ((TempString = StrStr(PathToReturn, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) { - *TempString = CHAR_NULL; - ChopLastSlash(PathToReturn); - } - while ((TempString = StrStr(PathToReturn, L"\\.\\")) != NULL) { - *TempString = CHAR_NULL; - TempString += 2; - TempSize = StrSize(TempString); - CopyMem(PathToReturn+StrLen(PathToReturn), TempString, TempSize); - } - if ((TempString = StrStr(PathToReturn, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) { - *TempString = CHAR_NULL; - } - return (PathToReturn); -} - -- cgit v1.2.3