]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - include/filenames.h
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / include / filenames.h
CommitLineData
5af11cab
AM
1/* Macros for taking apart, interpreting and processing file names.
2
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.
7
b3adc24a 8 Copyright (C) 2000-2020 Free Software Foundation, Inc.
5af11cab
AM
9
10This file is part of BFD, the Binary File Descriptor library.
11
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2 of the License, or
15(at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
e172dbf8 24Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
5af11cab
AM
25
26#ifndef FILENAMES_H
27#define FILENAMES_H
28
0429544a
DE
29#include "hashtab.h" /* for hashval_t */
30
91edef2d
ILT
31#ifdef __cplusplus
32extern "C" {
33#endif
34
4c89d75d 35#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
2cd2156f
DD
36# ifndef HAVE_DOS_BASED_FILE_SYSTEM
37# define HAVE_DOS_BASED_FILE_SYSTEM 1
38# endif
7d6b320b
JB
39# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
40# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
41# endif
2cd2156f
DD
42# define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f)
43# define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
44# define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
45#else /* not DOSish */
7d6b320b
JB
46# if defined(__APPLE__)
47# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
48# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
49# endif
50# endif /* __APPLE__ */
2cd2156f
DD
51# define HAS_DRIVE_SPEC(f) (0)
52# define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
53# define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
5af11cab
AM
54#endif
55
2cd2156f
DD
56#define IS_DIR_SEPARATOR_1(dos_based, c) \
57 (((c) == '/') \
58 || (((c) == '\\') && (dos_based)))
58cd9144 59
2cd2156f
DD
60#define HAS_DRIVE_SPEC_1(dos_based, f) \
61 ((f)[0] && ((f)[1] == ':') && (dos_based))
58cd9144
DE
62
63/* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f).
64 The result is a pointer to the remainder of F. */
65#define STRIP_DRIVE_SPEC(f) ((f) + 2)
66
2cd2156f
DD
67#define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c)
68#define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f)
69#define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f)
70
71#define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c)
72#define IS_UNIX_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (0, f)
73
74/* Note that when DOS_BASED is true, IS_ABSOLUTE_PATH accepts d:foo as
75 well, although it is only semi-absolute. This is because the users
76 of IS_ABSOLUTE_PATH want to know whether to prepend the current
77 working directory to a file name, which should not be done with a
78 name like d:foo. */
79#define IS_ABSOLUTE_PATH_1(dos_based, f) \
80 (IS_DIR_SEPARATOR_1 (dos_based, (f)[0]) \
81 || HAS_DRIVE_SPEC_1 (dos_based, f))
5af11cab 82
9c577e89
DD
83extern int filename_cmp (const char *s1, const char *s2);
84#define FILENAME_CMP(s1, s2) filename_cmp(s1, s2)
85
007d6189
KT
86extern int filename_ncmp (const char *s1, const char *s2,
87 size_t n);
88
0429544a
DE
89extern hashval_t filename_hash (const void *s);
90
91extern int filename_eq (const void *s1, const void *s2);
92
f7d13551
L
93extern int canonical_filename_eq (const char *a, const char *b);
94
91edef2d
ILT
95#ifdef __cplusplus
96}
97#endif
98
5af11cab 99#endif /* FILENAMES_H */