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