OSDN Git Service

update.
[putex/putex.git] / src / texsourc / xstat.h
1 /* xstat.h: declarations for using stat(2).
2
3    Copyright 1992 Karl Berry
4    Copyright 2007 TeX Users Group
5    Copyright 2014 Clerk Ma
6
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.
11
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.
16
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
20    02110-1301 USA.  */
21
22 #ifndef XSTAT_H
23 #define XSTAT_H
24
25 #include "types.h"
26 #include <sys/stat.h>
27
28
29 /* Predicates for testing file attributes.  */
30
31 #if !defined(S_ISBLK) && defined(S_IFBLK)
32 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
33 #endif
34 #if !defined(S_ISCHR) && defined(S_IFCHR)
35 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
36 #endif
37 #if !defined(S_ISDIR) && defined(S_IFDIR)
38 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
39 #endif
40 #if !defined(S_ISREG) && defined(S_IFREG)
41 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
42 #endif
43 #if !defined(S_ISFIFO) && defined(S_IFIFO)
44 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
45 #endif
46 #if !defined(S_ISLNK) && defined(S_IFLNK)
47 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
48 #endif
49 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
50 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
51 #endif
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)
55 #endif
56 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
57 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
58 #endif
59
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)
65
66 /* Does stat(2) on PATH, and aborts if the stat fails.  */
67 extern struct stat xstat P1H(string path);
68
69 /* Ditto, for lstat(2) (except that lstat might not exist).  */
70 #ifdef S_ISLNK
71 extern struct stat xlstat P1H(string path);
72 #else
73 #define xlstat xstat
74 #endif
75
76 #endif /* not XSTAT_H */