diff options
author | Jim.Dailey@dell.com <Jim.Dailey@dell.com> | 2018-10-30 05:14:36 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-11-05 10:52:40 +0800 |
commit | 9ba404d6644c61b3b4f792982517d981d882dc71 (patch) | |
tree | bf7556270f89e71c2df41cdd4cca59e0140c5378 /ShellPkg/Include | |
parent | e048ce883c8e9f746a655ca5a4c8c0ce34198999 (diff) | |
download | edk2-9ba404d6644c61b3b4f792982517d981d882dc71.tar.gz edk2-9ba404d6644c61b3b4f792982517d981d882dc71.tar.bz2 edk2-9ba404d6644c61b3b4f792982517d981d882dc71.zip |
ShellPkg-UefiShellLib: Add a function to fully-qualify paths
Add a function to return a clean, fully-qualified version of some path.
This function handles a (possibly "dirty") input path that may or may
not include a file system reference.
If it does not include a file system reference, then if the input path
does not begin with a forward or backward slash, then the input path is
relative to the current working directory of the current file system.
Otherwise, it is an absolute path within the current file system.
If it does include a file system reference, it may be a reference to the
current or some other file system. If the file system reference is not
immediately followed by a forward or backward slash, then the input path
is relative to the current working directory of the given file system.
Otherwise, it is an absolute path within the given file system.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Diffstat (limited to 'ShellPkg/Include')
-rw-r--r-- | ShellPkg/Include/Library/ShellLib.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Library/ShellLib.h index 92fddc50f5..2ecc5ee006 100644 --- a/ShellPkg/Include/Library/ShellLib.h +++ b/ShellPkg/Include/Library/ShellLib.h @@ -2,6 +2,7 @@ Provides interface to shell functionality for shell commands and applications.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright 2018 Dell Technologies.<BR>
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
@@ -36,6 +37,40 @@ extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol; extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;
/**
+ Return a clean, fully-qualified version of an input path. If the return value
+ is non-NULL the caller must free the memory when it is no longer needed.
+
+ If asserts are disabled, and if the input parameter is NULL, NULL is returned.
+
+ If there is not enough memory available to create the fully-qualified path or
+ a copy of the input path, NULL is returned.
+
+ If there is no working directory, a clean copy of Path is returned.
+
+ Otherwise, the current file system or working directory (as appropriate) is
+ prepended to Path and the resulting path is cleaned and returned.
+
+ NOTE: If the input path is an empty string, then the current working directory
+ (if it exists) is returned. In other words, an empty input path is treated
+ exactly the same as ".".
+
+ @param[in] Path A pointer to some file or directory path.
+
+ @retval NULL The input path is NULL or out of memory.
+
+ @retval non-NULL A pointer to a clean, fully-qualified version of Path.
+ If there is no working directory, then a pointer to a
+ clean, but not necessarily fully-qualified version of
+ Path. The caller must free this memory when it is no
+ longer needed.
+**/
+CHAR16*
+EFIAPI
+FullyQualifyPath(
+ IN CONST CHAR16 *Path
+ );
+
+/**
This function will retrieve the information about the file for the handle
specified and store it in allocated pool memory.
|