The OpenD Programming Language

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 
10 import core.sys.windows.stdc.time;
11 
12 // Posix version is in core.sys.posix.sys.stat
13 
14 enum S_IFMT   = 0xF000;
15 enum S_IFDIR  = 0x4000;
16 enum S_IFCHR  = 0x2000;
17 enum S_IFIFO  = 0x1000;
18 enum S_IFREG  = 0x8000;
19 enum S_IREAD  = 0x0100;
20 enum S_IWRITE = 0x0080;
21 enum S_IEXEC  = 0x0040;
22 enum S_IFBLK  = 0x6000;
23 enum S_IFNAM  = 0x5000;
24 
25 @safe pure
26 {
27 int S_ISREG(int m)  { return (m & S_IFMT) == S_IFREG; }
28 int S_ISBLK(int m)  { return (m & S_IFMT) == S_IFBLK; }
29 int S_ISNAM(int m)  { return (m & S_IFMT) == S_IFNAM; }
30 int S_ISDIR(int m)  { return (m & S_IFMT) == S_IFDIR; }
31 int S_ISCHR(int m)  { return (m & S_IFMT) == S_IFCHR; }
32 }
33 
34 version (CRuntime_DigitalMars)
35 {
36     struct struct_stat
37     {
38         short st_dev;
39         ushort st_ino;
40         ushort st_mode;
41         short st_nlink;
42         ushort st_uid;
43         ushort st_gid;
44         short st_rdev;
45         short dummy;
46         int st_size;
47         time_t st_atime;
48         time_t st_mtime;
49         time_t st_ctime;
50     }
51 
52     int stat(const(char)*, struct_stat *);
53     int fstat(int, struct_stat *) @trusted;
54     int _wstat(const(wchar)*, struct_stat *);
55 }
56 else version (CRuntime_Microsoft)
57 {
58     struct struct_stat
59     {
60         uint st_dev;
61         ushort st_ino;
62         ushort st_mode;
63         short st_nlink;
64         short st_uid;
65         short st_gid;
66         uint st_rdev;
67         int st_size;
68         time_t st_atime;
69         time_t st_mtime;
70         time_t st_ctime;
71     }
72 
73     // These assume time_t is 32 bits (which druntime's definition currently is)
74     // Add pragma(mangle) to use _stat64 etc. when time_t is made 64-bit
75     // See also: https://issues.dlang.org/show_bug.cgi?id=21134
76     int stat(const(char)*, struct_stat *);
77     int fstat(int, struct_stat *) @trusted;
78     int _wstat(const(wchar)*, struct_stat *);
79 }