1 /* xstat.h: declarations for using stat(2).
3 Copyright 1992 Karl Berry
4 Copyright 2007 TeX Users Group
5 Copyright 2014 Clerk Ma
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 /* Predicates for testing file attributes. */
31 #if !defined(S_ISBLK) && defined(S_IFBLK)
32 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
34 #if !defined(S_ISCHR) && defined(S_IFCHR)
35 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
37 #if !defined(S_ISDIR) && defined(S_IFDIR)
38 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
40 #if !defined(S_ISREG) && defined(S_IFREG)
41 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
43 #if !defined(S_ISFIFO) && defined(S_IFIFO)
44 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
46 #if !defined(S_ISLNK) && defined(S_IFLNK)
47 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
49 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
50 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
52 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
53 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
54 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
56 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
57 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
60 /* Two files are indistinguishable if they are on the same device
61 and have the same inode. This checks two stat buffers for that. */
62 /* NOTE: this doesn't work in DOS, since ino == 0 always */
63 #define SAME_FILE_P(s1, s2) \
64 ((s1).st_ino == (s2).st_ino && (s1).st_dev == (s2).st_dev)
66 /* Does stat(2) on PATH, and aborts if the stat fails. */
67 extern struct stat xstat P1H(string path);
69 /* Ditto, for lstat(2) (except that lstat might not exist). */
71 extern struct stat xlstat P1H(string path);
76 #endif /* not XSTAT_H */