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