1 /** @file
2 Header file for helper functions useful to operate file directories by parsing
3 file path.
4 
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 
8 **/
9 
10 #ifndef _EFI_OS_PATH_H
11 #define _EFI_OS_PATH_H
12 
13 #include <Common/UefiBaseTypes.h>
14 
15 //
16 // Functions declarations
17 //
18 
19 CHAR8*
20 OsPathDirName (
21   IN CHAR8    *FilePath
22   )
23 ;
24 /**
25 
26 Routine Description:
27 
28   This function returns the directory path which contains the particular path.
29   Some examples:
30     "a/b/c"  -> "a/b"
31     "a/b/c/" -> "a/b"
32     "a"      -> "."
33     "."      -> ".."
34     "/"      -> NULL
35 
36   This function does not check for the existence of the file.
37 
38   The caller must free the string returned.
39 
40 Arguments:
41 
42   FilePath     Path name of file to get the parent directory for.
43 
44 Returns:
45 
46   NULL if error
47 
48 **/
49 
50 
51 VOID
52 OsPathNormPathInPlace (
53   IN CHAR8    *Path
54   )
55 ;
56 /**
57 
58 Routine Description:
59 
60   This function returns the directory path which contains the particular path.
61   Some examples:
62     "a/b/../c" -> "a/c"
63     "a/b//c"   -> "a/b/c"
64     "a/./b"    -> "a/b"
65 
66   This function does not check for the existence of the file.
67 
68 Arguments:
69 
70   Path     Path name of file to normalize
71 
72 Returns:
73 
74   The string is altered in place.
75 
76 **/
77 
78 
79 CHAR8*
80 OsPathPeerFilePath (
81   IN CHAR8    *OldPath,
82   IN CHAR8    *Peer
83   )
84 ;
85 /**
86 
87 Routine Description:
88 
89   This function replaces the final portion of a path with an alternative
90   'peer' filename.  For example:
91     "a/b/../c", "peer" -> "a/b/../peer"
92     "a/b/", "peer"     -> "a/b/peer"
93     "/a", "peer"       -> "/peer"
94     "a", "peer"        -> "peer"
95 
96   This function does not check for the existence of the file.
97 
98 Arguments:
99 
100   OldPath     Path name of replace the final segment
101   Peer        The new path name to concatenate to become the peer path
102 
103 Returns:
104 
105   A CHAR8* string, which must be freed by the caller
106 
107 **/
108 
109 
110 BOOLEAN
111 OsPathExists (
112   IN CHAR8    *InputFileName
113   )
114 ;
115 /**
116 
117 Routine Description:
118 
119   Checks if a file exists
120 
121 Arguments:
122 
123   InputFileName     The name of the file to check for existence
124 
125 Returns:
126 
127   TRUE              The file exists
128   FALSE             The file does not exist
129 
130 **/
131 
132 
133 #endif
134