public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Jaben Carsey <jaben.carsey@intel.com>
Subject: [PATCH 4/6] MdePkg: Enhance PathRemoveLastItem() to support "FS0:File.txt"
Date: Mon,  8 Aug 2016 18:28:32 +0800	[thread overview]
Message-ID: <20160808102834.129372-5-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20160808102834.129372-1-ruiyu.ni@intel.com>

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 <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 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



  parent reply	other threads:[~2016-08-08 10:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 10:28 [PATCH 0/6] Fix shell TAB completion issue and bugs in LS command Ruiyu Ni
2016-08-08 10:28 ` [PATCH 1/6] ShellPkg: TAB logic incorrectly chops out fs0: when typing fs0:<TAB> Ruiyu Ni
2016-08-08 10:28 ` [PATCH 2/6] ShellPkg: TAB logic incorrectly shows files in CWD when typing \<TAB> Ruiyu Ni
2016-08-08 10:28 ` [PATCH 3/6] ShellPkg: Fix FindFiles() to handle "fsx:EFI\BOOT" path Ruiyu Ni
2016-08-08 10:28 ` Ruiyu Ni [this message]
2016-08-08 10:28 ` [PATCH 5/6] ShellPkg/ls: Fix to support "ls fs0:File.txt" Ruiyu Ni
2016-08-08 10:28 ` [PATCH 6/6] ShellPkg/ls: Display the correct directory path Ruiyu Ni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160808102834.129372-5-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox