1169695Skan/* Macros for taking apart, interpreting and processing file names.
2169695Skan
3169695Skan   These are here because some non-Posix (a.k.a. DOSish) systems have
4169695Skan   drive letter brain-damage at the beginning of an absolute file name,
5169695Skan   use forward- and back-slash in path names interchangeably, and
6169695Skan   some of them have case-insensitive file names.
7169695Skan
8169695Skan   Copyright 2000, 2001 Free Software Foundation, Inc.
9169695Skan
10169695SkanThis file is part of BFD, the Binary File Descriptor library.
11169695Skan
12169695SkanThis program is free software; you can redistribute it and/or modify
13169695Skanit under the terms of the GNU General Public License as published by
14169695Skanthe Free Software Foundation; either version 2 of the License, or
15169695Skan(at your option) any later version.
16169695Skan
17169695SkanThis program is distributed in the hope that it will be useful,
18169695Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
19169695SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20169695SkanGNU General Public License for more details.
21169695Skan
22169695SkanYou should have received a copy of the GNU General Public License
23169695Skanalong with this program; if not, write to the Free Software
24169695SkanFoundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
25169695Skan
26169695Skan#ifndef FILENAMES_H
27169695Skan#define FILENAMES_H
28169695Skan
29169695Skan#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
30169695Skan
31169695Skan#ifndef HAVE_DOS_BASED_FILE_SYSTEM
32169695Skan#define HAVE_DOS_BASED_FILE_SYSTEM 1
33169695Skan#endif
34169695Skan
35169695Skan#define IS_DIR_SEPARATOR(c)	((c) == '/' || (c) == '\\')
36169695Skan/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
37169695Skan   only semi-absolute.  This is because the users of IS_ABSOLUTE_PATH
38169695Skan   want to know whether to prepend the current working directory to
39169695Skan   a file name, which should not be done with a name like d:foo.  */
40169695Skan#define IS_ABSOLUTE_PATH(f)	(IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((f)[1] == ':')))
41169695Skan#define FILENAME_CMP(s1, s2)	strcasecmp(s1, s2)
42169695Skan
43169695Skan#else  /* not DOSish */
44169695Skan
45169695Skan#define IS_DIR_SEPARATOR(c)	((c) == '/')
46169695Skan#define IS_ABSOLUTE_PATH(f)	(IS_DIR_SEPARATOR((f)[0]))
47169695Skan#define FILENAME_CMP(s1, s2)	strcmp(s1, s2)
48169695Skan
49169695Skan#endif /* not DOSish */
50169695Skan
51169695Skan#endif /* FILENAMES_H */
52