-
Notifications
You must be signed in to change notification settings - Fork 119
/
stat.h
249 lines (210 loc) · 6.39 KB
/
stat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//
// sys/stat.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The _stat() and _fstat() families of functions.
//
#pragma once
#include <corecrt.h>
#include <sys/types.h>
#pragma warning(push)
#pragma warning(disable: _UCRT_DISABLED_WARNINGS)
_UCRT_DISABLE_CLANG_WARNINGS
_CRT_BEGIN_C_HEADER
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// Types
//
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
struct _stat32
{
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
__time32_t st_atime;
__time32_t st_mtime;
__time32_t st_ctime;
};
struct _stat32i64
{
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
__int64 st_size;
__time32_t st_atime;
__time32_t st_mtime;
__time32_t st_ctime;
};
struct _stat64i32
{
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
__time64_t st_atime;
__time64_t st_mtime;
__time64_t st_ctime;
};
struct _stat64
{
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
__int64 st_size;
__time64_t st_atime;
__time64_t st_mtime;
__time64_t st_ctime;
};
#define __stat64 _stat64 // For legacy compatibility
#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES && !defined _CRT_NO_TIME_T
struct stat
{
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#endif
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// Flags
//
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define _S_IFMT 0xF000 // File type mask
#define _S_IFDIR 0x4000 // Directory
#define _S_IFCHR 0x2000 // Character special
#define _S_IFIFO 0x1000 // Pipe
#define _S_IFREG 0x8000 // Regular
#define _S_IREAD 0x0100 // Read permission, owner
#define _S_IWRITE 0x0080 // Write permission, owner
#define _S_IEXEC 0x0040 // Execute/search permission, owner
#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES
#define S_IFMT _S_IFMT
#define S_IFDIR _S_IFDIR
#define S_IFCHR _S_IFCHR
#define S_IFREG _S_IFREG
#define S_IREAD _S_IREAD
#define S_IWRITE _S_IWRITE
#define S_IEXEC _S_IEXEC
#endif
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// Functions
//
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#ifdef _USE_32BIT_TIME_T
#define _fstat _fstat32
#define _fstati64 _fstat32i64
#define _stat _stat32
#define _stati64 _stat32i64
#define _wstat _wstat32
#define _wstati64 _wstat32i64
#else
#define _fstat _fstat64i32
#define _fstati64 _fstat64
#define _stat _stat64i32
#define _stati64 _stat64
#define _wstat _wstat64i32
#define _wstati64 _wstat64
#endif
_ACRTIMP int __cdecl _fstat32(
_In_ int _FileHandle,
_Out_ struct _stat32* _Stat
);
_ACRTIMP int __cdecl _fstat32i64(
_In_ int _FileHandle,
_Out_ struct _stat32i64* _Stat
);
_ACRTIMP int __cdecl _fstat64i32(
_In_ int _FileHandle,
_Out_ struct _stat64i32* _Stat
);
_ACRTIMP int __cdecl _fstat64(
_In_ int _FileHandle,
_Out_ struct _stat64* _Stat
);
_ACRTIMP int __cdecl _stat32(
_In_z_ char const* _FileName,
_Out_ struct _stat32* _Stat
);
_ACRTIMP int __cdecl _stat32i64(
_In_z_ char const* _FileName,
_Out_ struct _stat32i64* _Stat
);
_ACRTIMP int __cdecl _stat64i32(
_In_z_ char const* _FileName,
_Out_ struct _stat64i32* _Stat
);
_ACRTIMP int __cdecl _stat64(
_In_z_ char const* _FileName,
_Out_ struct _stat64* _Stat
);
_ACRTIMP int __cdecl _wstat32(
_In_z_ wchar_t const* _FileName,
_Out_ struct _stat32* _Stat
);
_ACRTIMP int __cdecl _wstat32i64(
_In_z_ wchar_t const* _FileName,
_Out_ struct _stat32i64* _Stat
);
_ACRTIMP int __cdecl _wstat64i32(
_In_z_ wchar_t const* _FileName,
_Out_ struct _stat64i32* _Stat
);
_ACRTIMP int __cdecl _wstat64(
_In_z_ wchar_t const* _FileName,
_Out_ struct _stat64* _Stat
);
#if !defined RC_INVOKED && !defined __midl && defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES && !defined _CRT_NO_TIME_T
#ifdef _USE_32BIT_TIME_T
static __inline int __CRTDECL fstat(int const _FileHandle, struct stat* const _Stat)
{
_STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat32));
return _fstat32(_FileHandle, (struct _stat32*)_Stat);
}
static __inline int __CRTDECL stat(char const* const _FileName, struct stat* const _Stat)
{
_STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat32));
return _stat32(_FileName, (struct _stat32*)_Stat);
}
#else
static __inline int __CRTDECL fstat(int const _FileHandle, struct stat* const _Stat)
{
_STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat64i32));
return _fstat64i32(_FileHandle, (struct _stat64i32*)_Stat);
}
static __inline int __CRTDECL stat(char const* const _FileName, struct stat* const _Stat)
{
_STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat64i32));
return _stat64i32(_FileName, (struct _stat64i32*)_Stat);
}
#endif
#endif
_CRT_END_C_HEADER
_UCRT_RESTORE_CLANG_WARNINGS
#pragma warning(pop) // _UCRT_DISABLED_WARNINGS