2N/A/* Take file names apart into directory and base names.
2N/A
2N/A Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation,
2N/A Inc.
2N/A
2N/A This program is free software: you can redistribute it and/or modify
2N/A it under the terms of the GNU General Public License as published by
2N/A the Free Software Foundation; either version 3 of the License, or
2N/A (at your option) any later version.
2N/A
2N/A This program is distributed in the hope that it will be useful,
2N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A GNU General Public License for more details.
2N/A
2N/A You should have received a copy of the GNU General Public License
2N/A along with this program. If not, see <http://www.gnu.org/licenses/>. */
2N/A
2N/A#ifndef DIRNAME_H_
2N/A# define DIRNAME_H_ 1
2N/A
2N/A# include <stdbool.h>
2N/A# include <stddef.h>
2N/A
2N/A# ifndef DIRECTORY_SEPARATOR
2N/A# define DIRECTORY_SEPARATOR '/'
2N/A# endif
2N/A
2N/A# ifndef ISSLASH
2N/A# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
2N/A# endif
2N/A
2N/A# ifndef FILE_SYSTEM_PREFIX_LEN
2N/A# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
2N/A /* This internal macro assumes ASCII, but all hosts that support drive
2N/A letters use ASCII. */
2N/A# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
2N/A <= 'z' - 'a')
2N/A# define FILE_SYSTEM_PREFIX_LEN(Filename) \
2N/A (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
2N/A# else
2N/A# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
2N/A# endif
2N/A# endif
2N/A
2N/A# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
2N/A# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
2N/A# endif
2N/A
2N/A# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
2N/A# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
2N/A# endif
2N/A
2N/A# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
2N/A# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
2N/A# else
2N/A# define IS_ABSOLUTE_FILE_NAME(F) \
2N/A (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
2N/A# endif
2N/A# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
2N/A
2N/A# if GNULIB_DIRNAME
2N/Achar *base_name (char const *file);
2N/Achar *dir_name (char const *file);
2N/A# endif
2N/A
2N/Achar *mdir_name (char const *file);
2N/Asize_t base_len (char const *file);
2N/Asize_t dir_len (char const *file);
2N/Achar *last_component (char const *file);
2N/A
2N/Abool strip_trailing_slashes (char *file);
2N/A
2N/A#endif /* not DIRNAME_H_ */