From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ml01.01.org (Postfix) with ESMTP id 6D1071A1E20 for ; Mon, 8 Aug 2016 03:28:42 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 08 Aug 2016 03:28:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,489,1464678000"; d="scan'208";a="861587498" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga003.jf.intel.com with ESMTP; 08 Aug 2016 03:28:41 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey Date: Mon, 8 Aug 2016 18:28:32 +0800 Message-Id: <20160808102834.129372-5-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20160808102834.129372-1-ruiyu.ni@intel.com> References: <20160808102834.129372-1-ruiyu.ni@intel.com> Subject: [PATCH 4/6] MdePkg: Enhance PathRemoveLastItem() to support "FS0:File.txt" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2016 10:28:42 -0000 The original implementation only looks for very last backslash and removes the string after that. But when the path is like "FS0:File.txt" which doesn't contain backslash, the function cannot work well. The patch enhances the code to look for very last backslash or colon to support the path which doesn't contain backslash. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Jaben Carsey --- MdePkg/Library/BaseLib/FilePaths.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/BaseLib/FilePaths.c b/MdePkg/Library/BaseLib/FilePaths.c index c72ef72..c8da6bb 100644 --- a/MdePkg/Library/BaseLib/FilePaths.c +++ b/MdePkg/Library/BaseLib/FilePaths.c @@ -17,7 +17,8 @@ /** Removes the last directory or file entry in a path by changing the last - L'\' to a CHAR_NULL. + L'\' to a CHAR_NULL. For a path which is like L"fs0:startup.nsh", + it's converted to L"fs0:". @param[in,out] Path A pointer to the path to modify. @@ -39,7 +40,7 @@ PathRemoveLastItem( ; Walker != NULL && *Walker != CHAR_NULL ; Walker++ ){ - if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) { + if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) { LastSlash = Walker+1; } } -- 2.9.0.windows.1