xref: /netbsd-src/external/gpl3/gcc/dist/libphobos/libdruntime/core/sys/windows/stat.d (revision 0a3071956a3a9fdebdbf7f338cf2d439b45fc728)
1 
2 /// $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
3 /// Author: Walter Bright
4 
5 module core.sys.windows.stat;
6 version (Windows):
7 
8 extern (C) nothrow @nogc:
9 @system:
10 
11 import core.sys.windows.stdc.time;
12 
13 // Posix version is in core.sys.posix.sys.stat
14 
15 enum S_IFMT   = 0xF000;
16 enum S_IFDIR  = 0x4000;
17 enum S_IFCHR  = 0x2000;
18 enum S_IFIFO  = 0x1000;
19 enum S_IFREG  = 0x8000;
20 enum S_IREAD  = 0x0100;
21 enum S_IWRITE = 0x0080;
22 enum S_IEXEC  = 0x0040;
23 enum S_IFBLK  = 0x6000;
24 enum S_IFNAM  = 0x5000;
25 
26 @safe pure
27 {
S_ISREG(int m)28 int S_ISREG(int m)  { return (m & S_IFMT) == S_IFREG; }
S_ISBLK(int m)29 int S_ISBLK(int m)  { return (m & S_IFMT) == S_IFBLK; }
S_ISNAM(int m)30 int S_ISNAM(int m)  { return (m & S_IFMT) == S_IFNAM; }
S_ISDIR(int m)31 int S_ISDIR(int m)  { return (m & S_IFMT) == S_IFDIR; }
S_ISCHR(int m)32 int S_ISCHR(int m)  { return (m & S_IFMT) == S_IFCHR; }
33 }
34 
version(CRuntime_DigitalMars)35 version (CRuntime_DigitalMars)
36 {
37     struct struct_stat
38     {
39         short st_dev;
40         ushort st_ino;
41         ushort st_mode;
42         short st_nlink;
43         ushort st_uid;
44         ushort st_gid;
45         short st_rdev;
46         short dummy;
47         int st_size;
48         time_t st_atime;
49         time_t st_mtime;
50         time_t st_ctime;
51     }
52 
53     int stat(const(char)*, struct_stat *);
54     int fstat(int, struct_stat *) @trusted;
55     int _wstat(const(wchar)*, struct_stat *);
56 }
version(CRuntime_Microsoft)57 else version (CRuntime_Microsoft)
58 {
59     struct struct_stat
60     {
61         uint st_dev;
62         ushort st_ino;
63         ushort st_mode;
64         short st_nlink;
65         short st_uid;
66         short st_gid;
67         uint st_rdev;
68         int st_size;
69         time_t st_atime;
70         time_t st_mtime;
71         time_t st_ctime;
72     }
73 
74     // These assume time_t is 32 bits (which druntime's definition currently is)
75     // Add pragma(mangle) to use _stat64 etc. when time_t is made 64-bit
76     // See also: https://issues.dlang.org/show_bug.cgi?id=21134
77     int stat(const(char)*, struct_stat *);
78     int fstat(int, struct_stat *) @trusted;
79     int _wstat(const(wchar)*, struct_stat *);
80 }
81