ff4e5ac6e75d433dbc6b452ac213be6b96a50278
1 /* Macros for taking apart, interpreting and processing file names.
3 These are here because some non-Posix (a.k.a. DOSish) systems have
4 drive letter brain-damage at the beginning of an absolute file name,
5 use forward- and back-slash in path names interchangeably, and
6 some of them have case-insensitive file names.
8 Copyright 2000, 2001, 2007, 2010 Free Software Foundation, Inc.
10 This file is part of BFD, the Binary File Descriptor library.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
33 #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
34 # ifndef HAVE_DOS_BASED_FILE_SYSTEM
35 # define HAVE_DOS_BASED_FILE_SYSTEM 1
37 # define PATH_SEPARATOR ';'
38 # define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f)
39 # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
40 # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
41 #else /* not DOSish */
42 # define PATH_SEPARATOR ':'
43 # define HAS_DRIVE_SPEC(f) (0)
44 # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
45 # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
48 #define IS_DIR_SEPARATOR_1(dos_based, c) \
50 || (((c) == '\\') && (dos_based)))
52 #define HAS_DRIVE_SPEC_1(dos_based, f) \
53 ((f)[0] && ((f)[1] == ':') && (dos_based))
55 /* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f).
56 The result is a pointer to the remainder of F. */
57 #define STRIP_DRIVE_SPEC(f) ((f) + 2)
59 #define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c)
60 #define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f)
61 #define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f)
63 #define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c)
64 #define IS_UNIX_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (0, f)
66 /* Note that when DOS_BASED is true, IS_ABSOLUTE_PATH accepts d:foo as
67 well, although it is only semi-absolute. This is because the users
68 of IS_ABSOLUTE_PATH want to know whether to prepend the current
69 working directory to a file name, which should not be done with a
71 #define IS_ABSOLUTE_PATH_1(dos_based, f) \
72 (IS_DIR_SEPARATOR_1 (dos_based, (f)[0]) \
73 || HAS_DRIVE_SPEC_1 (dos_based, f))
75 extern int filename_cmp (const char *s1
, const char *s2
);
76 #define FILENAME_CMP(s1, s2) filename_cmp(s1, s2)
82 #endif /* FILENAMES_H */