dirname.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Take file names apart into directory and base names.
  2. Copyright (C) 1998, 2001, 2003-2006, 2009-2021 Free Software Foundation,
  3. Inc.
  4. This file is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. This file is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  14. #ifndef DIRNAME_H_
  15. # define DIRNAME_H_ 1
  16. # include <stdbool.h>
  17. # include <stdlib.h>
  18. # include "filename.h"
  19. # include "basename-lgpl.h"
  20. # ifndef DIRECTORY_SEPARATOR
  21. # define DIRECTORY_SEPARATOR '/'
  22. # endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. # if GNULIB_DIRNAME
  27. char *base_name (char const *file)
  28. _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
  29. _GL_ATTRIBUTE_RETURNS_NONNULL;
  30. char *dir_name (char const *file)
  31. _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
  32. _GL_ATTRIBUTE_RETURNS_NONNULL;
  33. # endif
  34. char *mdir_name (char const *file)
  35. _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
  36. size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
  37. bool strip_trailing_slashes (char *file);
  38. #ifdef __cplusplus
  39. } /* extern "C" */
  40. #endif
  41. #endif /* not DIRNAME_H_ */