annotate lib/dirname.h @ 273:88bbffa404ea 2.5 2.5

Updated version for release
author lost
date Sun, 16 Aug 2009 17:18:11 +0000
parents d5392bb5da3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
d5392bb5da3c Added generated files
lost
parents:
diff changeset
1 /* Take file names apart into directory and base names.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
2
d5392bb5da3c Added generated files
lost
parents:
diff changeset
3 Copyright (C) 1998, 2001, 2003-2006 Free Software Foundation, Inc.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
4
d5392bb5da3c Added generated files
lost
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
d5392bb5da3c Added generated files
lost
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
d5392bb5da3c Added generated files
lost
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
d5392bb5da3c Added generated files
lost
parents:
diff changeset
8 (at your option) any later version.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
9
d5392bb5da3c Added generated files
lost
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d5392bb5da3c Added generated files
lost
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5392bb5da3c Added generated files
lost
parents:
diff changeset
13 GNU General Public License for more details.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
14
d5392bb5da3c Added generated files
lost
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
d5392bb5da3c Added generated files
lost
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
d5392bb5da3c Added generated files
lost
parents:
diff changeset
17
d5392bb5da3c Added generated files
lost
parents:
diff changeset
18 #ifndef DIRNAME_H_
d5392bb5da3c Added generated files
lost
parents:
diff changeset
19 # define DIRNAME_H_ 1
d5392bb5da3c Added generated files
lost
parents:
diff changeset
20
d5392bb5da3c Added generated files
lost
parents:
diff changeset
21 # include <stdbool.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
22 # include <stddef.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
23
d5392bb5da3c Added generated files
lost
parents:
diff changeset
24 # ifndef DIRECTORY_SEPARATOR
d5392bb5da3c Added generated files
lost
parents:
diff changeset
25 # define DIRECTORY_SEPARATOR '/'
d5392bb5da3c Added generated files
lost
parents:
diff changeset
26 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
27
d5392bb5da3c Added generated files
lost
parents:
diff changeset
28 # ifndef ISSLASH
d5392bb5da3c Added generated files
lost
parents:
diff changeset
29 # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
d5392bb5da3c Added generated files
lost
parents:
diff changeset
30 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
31
d5392bb5da3c Added generated files
lost
parents:
diff changeset
32 # ifndef FILE_SYSTEM_PREFIX_LEN
d5392bb5da3c Added generated files
lost
parents:
diff changeset
33 # if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
d5392bb5da3c Added generated files
lost
parents:
diff changeset
34 /* This internal macro assumes ASCII, but all hosts that support drive
d5392bb5da3c Added generated files
lost
parents:
diff changeset
35 letters use ASCII. */
d5392bb5da3c Added generated files
lost
parents:
diff changeset
36 # define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
d5392bb5da3c Added generated files
lost
parents:
diff changeset
37 <= 'z' - 'a')
d5392bb5da3c Added generated files
lost
parents:
diff changeset
38 # define FILE_SYSTEM_PREFIX_LEN(Filename) \
d5392bb5da3c Added generated files
lost
parents:
diff changeset
39 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
d5392bb5da3c Added generated files
lost
parents:
diff changeset
40 # else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
41 # define FILE_SYSTEM_PREFIX_LEN(Filename) 0
d5392bb5da3c Added generated files
lost
parents:
diff changeset
42 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
43 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
44
d5392bb5da3c Added generated files
lost
parents:
diff changeset
45 # ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
d5392bb5da3c Added generated files
lost
parents:
diff changeset
46 # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
d5392bb5da3c Added generated files
lost
parents:
diff changeset
47 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
48
d5392bb5da3c Added generated files
lost
parents:
diff changeset
49 # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
d5392bb5da3c Added generated files
lost
parents:
diff changeset
50 # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
d5392bb5da3c Added generated files
lost
parents:
diff changeset
51 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
52
d5392bb5da3c Added generated files
lost
parents:
diff changeset
53 # if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
d5392bb5da3c Added generated files
lost
parents:
diff changeset
54 # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
d5392bb5da3c Added generated files
lost
parents:
diff changeset
55 # else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
56 # define IS_ABSOLUTE_FILE_NAME(F) \
d5392bb5da3c Added generated files
lost
parents:
diff changeset
57 (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
d5392bb5da3c Added generated files
lost
parents:
diff changeset
58 # endif
d5392bb5da3c Added generated files
lost
parents:
diff changeset
59 # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
d5392bb5da3c Added generated files
lost
parents:
diff changeset
60
d5392bb5da3c Added generated files
lost
parents:
diff changeset
61 char *base_name (char const *file);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
62 char *dir_name (char const *file);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
63 size_t base_len (char const *file);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
64 size_t dir_len (char const *file);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
65 char *last_component (char const *file);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
66
d5392bb5da3c Added generated files
lost
parents:
diff changeset
67 bool strip_trailing_slashes (char *file);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
68
d5392bb5da3c Added generated files
lost
parents:
diff changeset
69 #endif /* not DIRNAME_H_ */