From patchwork Mon Mar 24 20:22:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Martin X-Patchwork-Id: 26957 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9D7A020143 for ; Mon, 24 Mar 2014 20:23:33 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id if11sf15061500vcb.8 for ; Mon, 24 Mar 2014 13:23:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=kakFBnN7ZHiAHMxXHNikxQn/ORrzoXhzQAzUG6XaYaE=; b=W70o91ByeXiJInaE5dpmRcVJNz7sXj0K7wrIicZ9gI617apuGgOkJeX7087m4HavDC Ij1iJtd7cSdflCufgzvh9ZRn8vSp++1LioD39fBfhViD0VuewcXHmAraiw4hezFfmFf6 HBD8t82xZJUOS+nmTPHdi7bzk7Is9IFUpplJpnqlWdYuMxxWm3CwSkjhkfKIXiJXaFVO KtffabKmqGpIE6T9ZkT7VfGDCmIeg1mmiz+JcS4TWMWNWgXjKtYbAzWFK3N3qAxt6A5V vkwqmyu/W6LA2TVVj4tKnfQ+rMTRprPumsk7Krzb9tE7s4xiCNdvMA+55FXAc2Z15+MW xbPg== X-Gm-Message-State: ALoCoQniAt9zlvRK3+vRPX+j7/Ii9jdwq5wE2dWG+CbyiZvmCG2XZy4+yCwnOC6vYLrp34xLS6BM X-Received: by 10.236.83.197 with SMTP id q45mr16689286yhe.10.1395692613386; Mon, 24 Mar 2014 13:23:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.203 with SMTP id n69ls1733891qgd.96.gmail; Mon, 24 Mar 2014 13:23:33 -0700 (PDT) X-Received: by 10.220.10.2 with SMTP id n2mr2457579vcn.26.1395692613253; Mon, 24 Mar 2014 13:23:33 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id rx10si3342385vdc.78.2014.03.24.13.23.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Mar 2014 13:23:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so6175951veb.39 for ; Mon, 24 Mar 2014 13:23:33 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr2275207vck.29.1395692613158; Mon, 24 Mar 2014 13:23:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp252193vck; Mon, 24 Mar 2014 13:23:32 -0700 (PDT) X-Received: by 10.43.74.198 with SMTP id yx6mr52813641icb.40.1395692612377; Mon, 24 Mar 2014 13:23:32 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ac8si16565698icc.18.2014.03.24.13.23.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Mar 2014 13:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WSBP2-0003n3-4m; Mon, 24 Mar 2014 20:23:24 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WSBOz-0003mv-UJ for edk2-devel@lists.sourceforge.net; Mon, 24 Mar 2014 20:23:21 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of arm.com designates 217.140.96.21 as permitted sender) client-ip=217.140.96.21; envelope-from=olivier.martin@arm.com; helo=cam-smtp0.cambridge.arm.com; Received: from fw-tnat.cambridge.arm.com ([217.140.96.21] helo=cam-smtp0.cambridge.arm.com) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1WSBOx-0002w1-LD for edk2-devel@lists.sourceforge.net; Mon, 24 Mar 2014 20:23:21 +0000 Received: from e102605-lin.cambridge.arm.com (e102605-lin.cambridge.arm.com [10.1.193.42]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s2OKN7kx017891; Mon, 24 Mar 2014 20:23:08 GMT From: Olivier Martin To: feng.tian@intel.com Date: Mon, 24 Mar 2014 20:22:58 +0000 Message-Id: <1395692580-24875-2-git-send-email-olivier.martin@arm.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1395692580-24875-1-git-send-email-olivier.martin@arm.com> References: <1395692580-24875-1-git-send-email-olivier.martin@arm.com> X-Spam-Score: -2.0 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1WSBOx-0002w1-LD Cc: Brendan Jackman , edk2-devel@lists.sourceforge.net Subject: [edk2] [PATCH 1/3] Move BasePathLib from ShellPkg to MdeModulePkg X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: olivier.martin@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Brendan Jackman This library is useful to other modules than the shell - for example filesystem drivers. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackman Reviewed-by: Olivier Martin --- AppPkg/AppPkg.dsc | 2 +- EmulatorPkg/EmulatorPkg.dsc | 2 +- MdeModulePkg/Include/Library/PathLib.h | 56 +++++++++++ MdeModulePkg/Library/BasePathLib/BasePathLib.c | 123 +++++++++++++++++++++++ MdeModulePkg/Library/BasePathLib/BasePathLib.inf | 38 +++++++ OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- ShellPkg/Include/Library/PathLib.h | 56 ----------- ShellPkg/Library/BasePathLib/BasePathLib.c | 123 ----------------------- ShellPkg/Library/BasePathLib/BasePathLib.inf | 38 ------- ShellPkg/ShellPkg.dsc | 2 +- StdLib/StdLib.dsc | 2 +- StdLib/StdLib.inc | 2 +- 14 files changed, 225 insertions(+), 225 deletions(-) create mode 100644 MdeModulePkg/Include/Library/PathLib.h create mode 100644 MdeModulePkg/Library/BasePathLib/BasePathLib.c create mode 100644 MdeModulePkg/Library/BasePathLib/BasePathLib.inf delete mode 100644 ShellPkg/Include/Library/PathLib.h delete mode 100644 ShellPkg/Library/BasePathLib/BasePathLib.c delete mode 100644 ShellPkg/Library/BasePathLib/BasePathLib.inf diff --git a/AppPkg/AppPkg.dsc b/AppPkg/AppPkg.dsc index d0aac2c..491332a 100644 --- a/AppPkg/AppPkg.dsc +++ b/AppPkg/AppPkg.dsc @@ -82,7 +82,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc index f1cb780..fb580d6 100644 --- a/EmulatorPkg/EmulatorPkg.dsc +++ b/EmulatorPkg/EmulatorPkg.dsc @@ -391,7 +391,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf # MemoryAllocationLib|EmulatorPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf # SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf # SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf diff --git a/MdeModulePkg/Include/Library/PathLib.h b/MdeModulePkg/Include/Library/PathLib.h new file mode 100644 index 0000000..ee47352 --- /dev/null +++ b/MdeModulePkg/Include/Library/PathLib.h @@ -0,0 +1,56 @@ +/** @file + Provides interface to path manipulation functions. + + Copyright (c) 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ + +#ifndef _PATH_LIB_ +#define _PATH_LIB_ + +#include +#include + +/** + Removes the last directory or file entry in a path by changing the last + L'\' to a CHAR_NULL. + + @param[in, out] Path The pointer to the path to modify. + + @retval FALSE Nothing was found to remove. + @retval TRUE A directory or file was removed. +**/ +BOOLEAN +EFIAPI +PathRemoveLastItem( + IN OUT CHAR16 *Path + ); + +/** + Function to clean up paths. + + - Single periods in the path are removed. + - Double periods in the path are removed along with a single parent directory. + - Forward slashes L'/' are converted to backward slashes L'\'. + + This will be done inline and the existing buffer may be larger than required + upon completion. + + @param[in] Path The pointer to the string containing the path. + + @retval NULL An error occured. + @return Path in all other instances. +**/ +CHAR16* +EFIAPI +PathCleanUpDirectories( + IN CHAR16 *Path + ); + +#endif //_PATH_LIB_ diff --git a/MdeModulePkg/Library/BasePathLib/BasePathLib.c b/MdeModulePkg/Library/BasePathLib/BasePathLib.c new file mode 100644 index 0000000..cc46c0f --- /dev/null +++ b/MdeModulePkg/Library/BasePathLib/BasePathLib.c @@ -0,0 +1,123 @@ +/** @file + Provides interface to path manipulation functions. + + Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ + +#include +#include +#include +#include +#include + +/** + Removes the last directory or file entry in a path by changing the last + L'\' to a CHAR_NULL. + + @param[in, out] Path The pointer to the path to modify. + + @retval FALSE Nothing was found to remove. + @retval TRUE A directory or file was removed. +**/ +BOOLEAN +EFIAPI +PathRemoveLastItem( + IN OUT CHAR16 *Path + ) +{ + CHAR16 *Walker; + CHAR16 *LastSlash; + // + // get directory name from path... ('chop' off extra) + // + for ( Walker = Path, 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. + + - Single periods in the path are removed. + - Double periods in the path are removed along with a single parent directory. + - Forward slashes L'/' are converted to backward slashes L'\'. + + This will be done inline and the existing buffer may be larger than required + upon completion. + + @param[in] Path The pointer to the string containing the path. + + @retval NULL An error occured. + @return Path in all other instances. +**/ +CHAR16* +EFIAPI +PathCleanUpDirectories( + IN CHAR16 *Path + ) +{ + CHAR16 *TempString; + UINTN TempSize; + if (Path==NULL) { + return(NULL); + } + + // + // Fix up the '/' vs '\' + // + for (TempString = Path ; TempString != NULL && *TempString != CHAR_NULL ; TempString++) { + if (*TempString == L'/') { + *TempString = L'\\'; + } + } + + // + // Fix up the .. + // + while ((TempString = StrStr(Path, L"\\..\\")) != NULL) { + *TempString = CHAR_NULL; + TempString += 4; + PathRemoveLastItem(Path); + TempSize = StrSize(TempString); + CopyMem(Path+StrLen(Path), TempString, TempSize); + } + if ((TempString = StrStr(Path, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) { + *TempString = CHAR_NULL; + PathRemoveLastItem(Path); + } + + // + // Fix up the . + // + while ((TempString = StrStr(Path, L"\\.\\")) != NULL) { + *TempString = CHAR_NULL; + TempString += 2; + TempSize = StrSize(TempString); + CopyMem(Path+StrLen(Path), TempString, TempSize); + } + if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) { + *(TempString + 1) = CHAR_NULL; + } + + + + return (Path); +} + diff --git a/MdeModulePkg/Library/BasePathLib/BasePathLib.inf b/MdeModulePkg/Library/BasePathLib/BasePathLib.inf new file mode 100644 index 0000000..7346968 --- /dev/null +++ b/MdeModulePkg/Library/BasePathLib/BasePathLib.inf @@ -0,0 +1,38 @@ +## @file +# Provides interface to path manipulation functions. +# +# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = BasePathLib + FILE_GUID = ED244F93-B97A-4a17-83E0-A03CF2A7F7B4 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = PathLib|UEFI_APPLICATION UEFI_DRIVER + +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources.common] + BasePathLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + + +[LibraryClasses] + BaseMemoryLib + BaseLib \ No newline at end of file diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 5adf4c0..9c51c82 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -538,7 +538,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf # SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf # SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 75ff5f0..7cd2715 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -545,7 +545,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf # SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf # SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 7a1e0ee..abf770d 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -543,7 +543,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf # SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf # SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf diff --git a/ShellPkg/Include/Library/PathLib.h b/ShellPkg/Include/Library/PathLib.h deleted file mode 100644 index ee47352..0000000 --- a/ShellPkg/Include/Library/PathLib.h +++ /dev/null @@ -1,56 +0,0 @@ -/** @file - Provides interface to path manipulation functions. - - Copyright (c) 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#ifndef _PATH_LIB_ -#define _PATH_LIB_ - -#include -#include - -/** - Removes the last directory or file entry in a path by changing the last - L'\' to a CHAR_NULL. - - @param[in, out] Path The pointer to the path to modify. - - @retval FALSE Nothing was found to remove. - @retval TRUE A directory or file was removed. -**/ -BOOLEAN -EFIAPI -PathRemoveLastItem( - IN OUT CHAR16 *Path - ); - -/** - Function to clean up paths. - - - Single periods in the path are removed. - - Double periods in the path are removed along with a single parent directory. - - Forward slashes L'/' are converted to backward slashes L'\'. - - This will be done inline and the existing buffer may be larger than required - upon completion. - - @param[in] Path The pointer to the string containing the path. - - @retval NULL An error occured. - @return Path in all other instances. -**/ -CHAR16* -EFIAPI -PathCleanUpDirectories( - IN CHAR16 *Path - ); - -#endif //_PATH_LIB_ diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.c b/ShellPkg/Library/BasePathLib/BasePathLib.c deleted file mode 100644 index cc46c0f..0000000 --- a/ShellPkg/Library/BasePathLib/BasePathLib.c +++ /dev/null @@ -1,123 +0,0 @@ -/** @file - Provides interface to path manipulation functions. - - Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include -#include -#include -#include - -/** - Removes the last directory or file entry in a path by changing the last - L'\' to a CHAR_NULL. - - @param[in, out] Path The pointer to the path to modify. - - @retval FALSE Nothing was found to remove. - @retval TRUE A directory or file was removed. -**/ -BOOLEAN -EFIAPI -PathRemoveLastItem( - IN OUT CHAR16 *Path - ) -{ - CHAR16 *Walker; - CHAR16 *LastSlash; - // - // get directory name from path... ('chop' off extra) - // - for ( Walker = Path, 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. - - - Single periods in the path are removed. - - Double periods in the path are removed along with a single parent directory. - - Forward slashes L'/' are converted to backward slashes L'\'. - - This will be done inline and the existing buffer may be larger than required - upon completion. - - @param[in] Path The pointer to the string containing the path. - - @retval NULL An error occured. - @return Path in all other instances. -**/ -CHAR16* -EFIAPI -PathCleanUpDirectories( - IN CHAR16 *Path - ) -{ - CHAR16 *TempString; - UINTN TempSize; - if (Path==NULL) { - return(NULL); - } - - // - // Fix up the '/' vs '\' - // - for (TempString = Path ; TempString != NULL && *TempString != CHAR_NULL ; TempString++) { - if (*TempString == L'/') { - *TempString = L'\\'; - } - } - - // - // Fix up the .. - // - while ((TempString = StrStr(Path, L"\\..\\")) != NULL) { - *TempString = CHAR_NULL; - TempString += 4; - PathRemoveLastItem(Path); - TempSize = StrSize(TempString); - CopyMem(Path+StrLen(Path), TempString, TempSize); - } - if ((TempString = StrStr(Path, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) { - *TempString = CHAR_NULL; - PathRemoveLastItem(Path); - } - - // - // Fix up the . - // - while ((TempString = StrStr(Path, L"\\.\\")) != NULL) { - *TempString = CHAR_NULL; - TempString += 2; - TempSize = StrSize(TempString); - CopyMem(Path+StrLen(Path), TempString, TempSize); - } - if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) { - *(TempString + 1) = CHAR_NULL; - } - - - - return (Path); -} - diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.inf b/ShellPkg/Library/BasePathLib/BasePathLib.inf deleted file mode 100644 index a9bd6a8..0000000 --- a/ShellPkg/Library/BasePathLib/BasePathLib.inf +++ /dev/null @@ -1,38 +0,0 @@ -## @file -# Provides interface to path manipulation functions. -# -# Copyright (c) 2011, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010006 - BASE_NAME = BasePathLib - FILE_GUID = ED244F93-B97A-4a17-83E0-A03CF2A7F7B4 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PathLib|UEFI_APPLICATION UEFI_DRIVER - -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources.common] - BasePathLib.c - -[Packages] - MdePkg/MdePkg.dec - ShellPkg/ShellPkg.dec - - -[LibraryClasses] - BaseMemoryLib - BaseLib \ No newline at end of file diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc index 3284c1c..86c5d4d 100644 --- a/ShellPkg/ShellPkg.dsc +++ b/ShellPkg/ShellPkg.dsc @@ -48,7 +48,7 @@ HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf [LibraryClasses.ARM] # diff --git a/StdLib/StdLib.dsc b/StdLib/StdLib.dsc index b0309e2..e3fe99a 100644 --- a/StdLib/StdLib.dsc +++ b/StdLib/StdLib.dsc @@ -82,7 +82,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf ################################################################################################### # diff --git a/StdLib/StdLib.inc b/StdLib/StdLib.inc index 0c8b04f..64604a3 100644 --- a/StdLib/StdLib.inc +++ b/StdLib/StdLib.inc @@ -28,7 +28,7 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf - PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf + PathLib|MdeModulePkg/Library/BasePathLib/BasePathLib.inf ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf #