]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/OsPath.h
Sync EDKII BaseTools to BaseTools project r1971
[mirror_edk2.git] / BaseTools / Source / C / Common / OsPath.h
1 /** @file
2
3 Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 OsPath.h
15
16 Abstract:
17
18 Header file for helper functions useful to operate file directories
19 by parsing file path.
20
21 **/
22
23 #ifndef _EFI_OS_PATH_H
24 #define _EFI_OS_PATH_H
25
26 #include <Common/UefiBaseTypes.h>
27
28 //
29 // Functions declarations
30 //
31
32 CHAR8*
33 OsPathDirName (
34 IN CHAR8 *FilePath
35 )
36 ;
37 /**
38
39 Routine Description:
40
41 This function returns the directory path which contains the particular path.
42 Some examples:
43 "a/b/c" -> "a/b"
44 "a/b/c/" -> "a/b"
45 "a" -> "."
46 "." -> ".."
47 "/" -> NULL
48
49 This function does not check for the existence of the file.
50
51 The caller must free the string returned.
52
53 Arguments:
54
55 FilePath Path name of file to get the parent directory for.
56
57 Returns:
58
59 NULL if error
60
61 **/
62
63
64 VOID
65 OsPathNormPathInPlace (
66 IN CHAR8 *Path
67 )
68 ;
69 /**
70
71 Routine Description:
72
73 This function returns the directory path which contains the particular path.
74 Some examples:
75 "a/b/../c" -> "a/c"
76 "a/b//c" -> "a/b/c"
77 "a/./b" -> "a/b"
78
79 This function does not check for the existence of the file.
80
81 Arguments:
82
83 Path Path name of file to normalize
84
85 Returns:
86
87 The string is altered in place.
88
89 **/
90
91
92 CHAR8*
93 OsPathPeerFilePath (
94 IN CHAR8 *OldPath,
95 IN CHAR8 *Peer
96 )
97 ;
98 /**
99
100 Routine Description:
101
102 This function replaces the final portion of a path with an alternative
103 'peer' filename. For example:
104 "a/b/../c", "peer" -> "a/b/../peer"
105 "a/b/", "peer" -> "a/b/peer"
106 "/a", "peer" -> "/peer"
107 "a", "peer" -> "peer"
108
109 This function does not check for the existence of the file.
110
111 Arguments:
112
113 OldPath Path name of replace the final segment
114 Peer The new path name to concatinate to become the peer path
115
116 Returns:
117
118 A CHAR8* string, which must be freed by the caller
119
120 **/
121
122
123 BOOLEAN
124 OsPathExists (
125 IN CHAR8 *InputFileName
126 )
127 ;
128 /**
129
130 Routine Description:
131
132 Checks if a file exists
133
134 Arguments:
135
136 InputFileName The name of the file to check for existence
137
138 Returns:
139
140 TRUE The file exists
141 FALSE The file does not exist
142
143 **/
144
145
146 #endif