OsPath.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. This program and the accompanying materials
  6. are licensed and made available under the terms and conditions of the BSD License
  7. which accompanies this distribution. The full text of the license may be found at
  8. http://opensource.org/licenses/bsd-license.php
  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. #ifndef _EFI_OS_PATH_H
  13. #define _EFI_OS_PATH_H
  14. #include <Common/UefiBaseTypes.h>
  15. //
  16. // Functions declarations
  17. //
  18. CHAR8*
  19. OsPathDirName (
  20. IN CHAR8 *FilePath
  21. )
  22. ;
  23. /**
  24. Routine Description:
  25. This function returns the directory path which contains the particular path.
  26. Some examples:
  27. "a/b/c" -> "a/b"
  28. "a/b/c/" -> "a/b"
  29. "a" -> "."
  30. "." -> ".."
  31. "/" -> NULL
  32. This function does not check for the existence of the file.
  33. The caller must free the string returned.
  34. Arguments:
  35. FilePath Path name of file to get the parent directory for.
  36. Returns:
  37. NULL if error
  38. **/
  39. VOID
  40. OsPathNormPathInPlace (
  41. IN CHAR8 *Path
  42. )
  43. ;
  44. /**
  45. Routine Description:
  46. This function returns the directory path which contains the particular path.
  47. Some examples:
  48. "a/b/../c" -> "a/c"
  49. "a/b//c" -> "a/b/c"
  50. "a/./b" -> "a/b"
  51. This function does not check for the existence of the file.
  52. Arguments:
  53. Path Path name of file to normalize
  54. Returns:
  55. The string is altered in place.
  56. **/
  57. CHAR8*
  58. OsPathPeerFilePath (
  59. IN CHAR8 *OldPath,
  60. IN CHAR8 *Peer
  61. )
  62. ;
  63. /**
  64. Routine Description:
  65. This function replaces the final portion of a path with an alternative
  66. 'peer' filename. For example:
  67. "a/b/../c", "peer" -> "a/b/../peer"
  68. "a/b/", "peer" -> "a/b/peer"
  69. "/a", "peer" -> "/peer"
  70. "a", "peer" -> "peer"
  71. This function does not check for the existence of the file.
  72. Arguments:
  73. OldPath Path name of replace the final segment
  74. Peer The new path name to concatenate to become the peer path
  75. Returns:
  76. A CHAR8* string, which must be freed by the caller
  77. **/
  78. BOOLEAN
  79. OsPathExists (
  80. IN CHAR8 *InputFileName
  81. )
  82. ;
  83. /**
  84. Routine Description:
  85. Checks if a file exists
  86. Arguments:
  87. InputFileName The name of the file to check for existence
  88. Returns:
  89. TRUE The file exists
  90. FALSE The file does not exist
  91. **/
  92. #endif