OsPath.h 2.3 KB

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