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