]> code.delx.au - gnu-emacs/blob - lib/dosname.h
Update copyright year to 2015
[gnu-emacs] / lib / dosname.h
1 /* File names on MS-DOS/Windows systems.
2
3 Copyright (C) 2000-2001, 2004-2006, 2009-2015 Free Software
4 Foundation, Inc.
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 From Paul Eggert and Jim Meyering. */
20
21 #ifndef _DOSNAME_H
22 #define _DOSNAME_H
23
24 #if (defined _WIN32 || defined __WIN32__ || \
25 defined __MSDOS__ || defined __CYGWIN__ || \
26 defined __EMX__ || defined __DJGPP__)
27 /* This internal macro assumes ASCII, but all hosts that support drive
28 letters use ASCII. */
29 # define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
30 <= 'z' - 'a')
31 # define FILE_SYSTEM_PREFIX_LEN(Filename) \
32 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
33 # ifndef __CYGWIN__
34 # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
35 # endif
36 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
37 #else
38 # define FILE_SYSTEM_PREFIX_LEN(Filename) 0
39 # define ISSLASH(C) ((C) == '/')
40 #endif
41
42 #ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
43 # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
44 #endif
45
46 #if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
47 # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
48 # else
49 # define IS_ABSOLUTE_FILE_NAME(F) \
50 (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
51 #endif
52 #define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
53
54 #endif /* DOSNAME_H_ */