dirname.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Take file names apart into directory and base names.
  2. Copyright (C) 1998, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #ifndef DIRNAME_H_
  15. # define DIRNAME_H_ 1
  16. # include <stdbool.h>
  17. # include <stddef.h>
  18. # ifndef DIRECTORY_SEPARATOR
  19. # define DIRECTORY_SEPARATOR '/'
  20. # endif
  21. # ifndef ISSLASH
  22. # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
  23. # endif
  24. # ifndef FILE_SYSTEM_PREFIX_LEN
  25. # define FILE_SYSTEM_PREFIX_LEN(File_name) 0
  26. # endif
  27. # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
  28. # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
  29. char *base_name (char const *file);
  30. char *dir_name (char const *file);
  31. size_t base_len (char const *file);
  32. size_t dir_len (char const *file);
  33. bool strip_trailing_slashes (char *file);
  34. #endif /* not DIRNAME_H_ */