public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Jim.Dailey@dell.com" <Jim.Dailey@dell.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Carsey, Jaben" <jaben.carsey@intel.com>
Subject: Re: [PATCH v2 1/2] ShellPkg-UefiShellLib: Add a function to fully-qualify paths
Date: Tue, 30 Oct 2018 07:33:21 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BEE552B@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <517a9546603441cc868554cb350e8afe@ausx13mps335.AMER.DELL.COM>

> -----Original Message-----
> From: Jim.Dailey@dell.com <Jim.Dailey@dell.com>
> Sent: Tuesday, October 30, 2018 5:15 AM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [PATCH v2 1/2] ShellPkg-UefiShellLib: Add a function to fully-qualify
> paths
> 
> +CHAR16*
> +EFIAPI
> +FullyQualifyPath(
> +  IN     CONST CHAR16     *Path
> +  )
> +{
> +  CONST CHAR16         *WorkingPath;
> +  CONST CHAR16         *InputPath;
> +  CHAR16               *InputFileSystem;
> +  UINTN                FileSystemCharCount;
> +  CHAR16               *FullyQualifiedPath;
> +  UINTN                Size;
> +
> +  FullyQualifiedPath = NULL;
> +
> +  ASSERT(Path != NULL);
> +  //
> +  // Handle erroneous input when asserts are disabled.
> +  //
> +  if (Path == NULL) {
> +    return NULL;
> +  }
> +  //
> +  // In paths that contain ":", like fs0:dir/file.ext and fs2:\fqpath\file.ext,
> +  // we  have to consider the file system part separately from the "path"
> part.
> +  // If there is a file system in the path, we have to get the current working
> +  // directory for that file system. Then we need to use the part of the path
> +  // following the ":".  If a path does not contain ":", we use it as given.
> +  //
> +  InputPath = StrStr(Path, L":");
> +  if (InputPath != NULL) {
> +    InputPath++;
> +    FileSystemCharCount = ((UINTN)InputPath - (UINTN)Path +
> sizeof(CHAR16)) / sizeof(CHAR16);
> +    InputFileSystem = AllocateCopyPool(FileSystemCharCount *
> sizeof(CHAR16), Path);
> +    if (InputFileSystem != NULL) {
> +      InputFileSystem[FileSystemCharCount - 1] = CHAR_NULL;
> +    }
> +    WorkingPath = ShellGetCurrentDir(InputFileSystem);
> +    SHELL_FREE_NON_NULL(InputFileSystem);
> +    //
> +    // Handle the degenerate case where Path was only a file system
> reference.
> +    // In that case we return the current working directory of the file system.
> +    //
> +    if (InputPath == NULL) {

The "InputPath" should not be NULL.



  reply	other threads:[~2018-10-30  7:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 21:14 [PATCH v2 1/2] ShellPkg-UefiShellLib: Add a function to fully-qualify paths Jim.Dailey
2018-10-30  7:33 ` Ni, Ruiyu [this message]
2018-10-30 11:32   ` Jim.Dailey
2018-10-31  9:17     ` Ni, Ruiyu
2018-10-31 11:27       ` Jim.Dailey
2018-11-05  2:59         ` Ni, Ruiyu

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=734D49CCEBEEF84792F5B80ED585239D5BEE552B@SHSMSX104.ccr.corp.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