]> git.cworth.org Git - tar/blob - gnu/dirname.h
upstream: Fix extraction of device nodes.
[tar] / gnu / dirname.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /*  Take file names apart into directory and base names.
4
5     Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation,
6     Inc.
7
8     This program is free software: you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 3 of the License, or
11     (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21 #ifndef DIRNAME_H_
22 # define DIRNAME_H_ 1
23
24 # include <stdbool.h>
25 # include <stddef.h>
26
27 # ifndef DIRECTORY_SEPARATOR
28 #  define DIRECTORY_SEPARATOR '/'
29 # endif
30
31 # ifndef ISSLASH
32 #  define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
33 # endif
34
35 # ifndef FILE_SYSTEM_PREFIX_LEN
36 #  if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
37     /* This internal macro assumes ASCII, but all hosts that support drive
38        letters use ASCII.  */
39 #   define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
40                                 <= 'z' - 'a')
41 #   define FILE_SYSTEM_PREFIX_LEN(Filename) \
42            (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
43 #  else
44 #   define FILE_SYSTEM_PREFIX_LEN(Filename) 0
45 #  endif
46 # endif
47
48 # ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
49 #  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
50 # endif
51
52 # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
53 #  define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
54 # endif
55
56 # if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
57 #  define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
58 # else
59 #  define IS_ABSOLUTE_FILE_NAME(F) \
60           (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
61 # endif
62 # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
63
64 # if GNULIB_DIRNAME
65 char *base_name (char const *file);
66 char *dir_name (char const *file);
67 # endif
68
69 char *mdir_name (char const *file);
70 size_t base_len (char const *file);
71 size_t dir_len (char const *file);
72 char *last_component (char const *file);
73
74 bool strip_trailing_slashes (char *file);
75
76 #endif /* not DIRNAME_H_ */