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