OSDN Git Service

Create "legacy" branch; import mingwrt-3.20 source code.
[mingw/mingw-org-wsl.git] / mingwrt / include / sys / stat.h
1 /*
2  * stat.h
3  * This file has no copyright assigned and is placed in the Public Domain.
4  * This file is a part of the mingw-runtime package.
5  * No warranty is given; refer to the file DISCLAIMER within the package.
6  *
7  * Symbolic constants for opening and creating files, also stat, fstat and
8  * chmod functions.
9  *
10  */
11
12 #ifndef _STAT_H_
13 #define _STAT_H_
14
15 /* All the headers include this file. */
16 #include <_mingw.h>
17
18 #define __need_size_t
19 #define __need_wchar_t
20 #ifndef RC_INVOKED
21 #include <stddef.h>
22 #endif /* Not RC_INVOKED */
23
24 #include <sys/types.h>
25
26 /*
27  * Constants for the stat st_mode member.
28  */
29 #define _S_IFIFO        0x1000  /* FIFO */
30 #define _S_IFCHR        0x2000  /* Character */
31 #define _S_IFBLK        0x3000  /* Block: Is this ever set under w32? */
32 #define _S_IFDIR        0x4000  /* Directory */
33 #define _S_IFREG        0x8000  /* Regular */
34
35 #define _S_IFMT         0xF000  /* File type mask */
36
37 #define _S_IEXEC        0x0040
38 #define _S_IWRITE       0x0080
39 #define _S_IREAD        0x0100
40
41 #define _S_IRWXU        (_S_IREAD | _S_IWRITE | _S_IEXEC)
42 #define _S_IXUSR        _S_IEXEC
43 #define _S_IWUSR        _S_IWRITE
44 #define _S_IRUSR        _S_IREAD
45
46 #define _S_ISDIR(m)     (((m) & _S_IFMT) == _S_IFDIR)
47 #define _S_ISFIFO(m)    (((m) & _S_IFMT) == _S_IFIFO)
48 #define _S_ISCHR(m)     (((m) & _S_IFMT) == _S_IFCHR)
49 #define _S_ISBLK(m)     (((m) & _S_IFMT) == _S_IFBLK)
50 #define _S_ISREG(m)     (((m) & _S_IFMT) == _S_IFREG)
51
52 #ifndef _NO_OLDNAMES
53
54 #define S_IFIFO         _S_IFIFO
55 #define S_IFCHR         _S_IFCHR
56 #define S_IFBLK         _S_IFBLK
57 #define S_IFDIR         _S_IFDIR
58 #define S_IFREG         _S_IFREG
59 #define S_IFMT          _S_IFMT
60 #define S_IEXEC         _S_IEXEC
61 #define S_IWRITE        _S_IWRITE
62 #define S_IREAD         _S_IREAD
63 #define S_IRWXU         _S_IRWXU
64 #define S_IXUSR         _S_IXUSR
65 #define S_IWUSR         _S_IWUSR
66 #define S_IRUSR         _S_IRUSR
67
68 #define S_ISDIR(m)      (((m) & S_IFMT) == S_IFDIR)
69 #define S_ISFIFO(m)     (((m) & S_IFMT) == S_IFIFO)
70 #define S_ISCHR(m)      (((m) & S_IFMT) == S_IFCHR)
71 #define S_ISBLK(m)      (((m) & S_IFMT) == S_IFBLK)
72 #define S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)
73
74 #endif  /* Not _NO_OLDNAMES */
75
76 #ifndef RC_INVOKED
77
78 #ifndef _STAT_DEFINED
79 /*
80  * The structure manipulated and returned by stat and fstat.
81  *
82  * NOTE: If called on a directory the values in the time fields are not only
83  * invalid, they will cause localtime et. al. to return NULL. And calling
84  * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
85  */
86 struct _stat
87 {
88         _dev_t  st_dev;         /* Equivalent to drive number 0=A 1=B ... */
89         _ino_t  st_ino;         /* Always zero ? */
90         _mode_t st_mode;        /* See above constants */
91         short   st_nlink;       /* Number of links. */
92         short   st_uid;         /* User: Maybe significant on NT ? */
93         short   st_gid;         /* Group: Ditto */
94         _dev_t  st_rdev;        /* Seems useless (not even filled in) */
95         _off_t  st_size;        /* File size in bytes */
96         time_t  st_atime;       /* Accessed date (always 00:00 hrs local
97                                  * on FAT) */
98         time_t  st_mtime;       /* Modified time */
99         time_t  st_ctime;       /* Creation time */
100 };
101
102 #ifndef _NO_OLDNAMES
103 /* NOTE: Must be the same as _stat above. */
104 struct stat
105 {
106         dev_t   st_dev;         /* Equivalent to drive number 0=A 1=B ... */
107         ino_t   st_ino;         /* Always zero ? */
108         mode_t  st_mode;        /* See above constants */
109         short   st_nlink;       /* Number of links. */
110         short   st_uid;         /* User: Maybe significant on NT ? */
111         short   st_gid;         /* Group: Ditto */
112         dev_t   st_rdev;        /* Seems useless (not even filled in) */
113         off_t   st_size;        /* File size in bytes */
114         time_t  st_atime;       /* Accessed date (always 00:00 hrs local
115                                  * on FAT) */
116         time_t  st_mtime;       /* Modified time */
117         time_t  st_ctime;       /* Creation time */
118 };
119 #endif /* _NO_OLDNAMES */
120
121 #if defined (__MSVCRT__)
122 struct _stati64 {
123     _dev_t st_dev;
124     _ino_t st_ino;
125     _mode_t st_mode;
126     short st_nlink;
127     short st_uid;
128     short st_gid;
129     _dev_t st_rdev;
130     __int64 st_size;
131     time_t st_atime;
132     time_t st_mtime;
133     time_t st_ctime;
134 };
135 #if __MSVCRT_VERSION__ >= 0x0601
136 struct __stat64
137 {
138     _dev_t st_dev;
139     _ino_t st_ino;
140     _mode_t st_mode;
141     short st_nlink;
142     short st_uid;
143     short st_gid;
144     _dev_t st_rdev;
145     __int64 st_size;
146     __time64_t st_atime;
147     __time64_t st_mtime;
148     __time64_t st_ctime;
149 };
150 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
151 #if __MSVCRT_VERSION__ >= 0x0800
152 struct __stat32
153 {
154         _dev_t          st_dev;
155         _ino_t          st_ino;
156         _mode_t         st_mode;
157         short           st_nlink;
158         short           st_uid;
159         short           st_gid;
160         _dev_t          st_rdev;
161         __int32         st_size;
162         __time32_t      st_atime;
163         __time32_t      st_mtime;
164         __time32_t      st_ctime;
165 };
166 struct _stat32i64 {
167         _dev_t          st_dev;
168         _ino_t          st_ino;
169         _mode_t         st_mode;
170         short           st_nlink;
171         short           st_uid;
172         short           st_gid;
173         _dev_t          st_rdev;
174         __int64         st_size;
175         __time32_t      st_atime;
176         __time32_t      st_mtime;
177         __time32_t      st_ctime;
178 };
179 struct _stat64i32 {
180         _dev_t          st_dev;
181         _ino_t          st_ino;
182         _mode_t         st_mode;
183         short           st_nlink;
184         short           st_uid;
185         short           st_gid;
186         _dev_t          st_rdev;
187         __int32         st_size;
188         __time64_t      st_atime;
189         __time64_t      st_mtime;
190         __time64_t      st_ctime;
191 };
192 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
193 #endif /* __MSVCRT__ */
194 #define _STAT_DEFINED
195 #endif /* _STAT_DEFINED */
196
197 #ifdef  __cplusplus
198 extern "C" {
199 #endif
200
201 #if __MSVCRT_VERSION__ < 0x0800
202 _CRTIMP int __cdecl __MINGW_NOTHROW     _fstat (int, struct _stat*);
203 #endif
204 _CRTIMP int __cdecl __MINGW_NOTHROW     _chmod (const char*, int);
205 #if __MSVCRT_VERSION__ < 0x0800
206 _CRTIMP int __cdecl __MINGW_NOTHROW     _stat (const char*, struct _stat*);
207 #endif
208
209 #ifndef _NO_OLDNAMES
210 /* FIXME for __MSVCRT_VERSION__ >= 0x0800 */
211 /* These functions live in liboldnames.a. */
212 _CRTIMP int __cdecl __MINGW_NOTHROW     fstat (int, struct stat*);
213 _CRTIMP int __cdecl __MINGW_NOTHROW     chmod (const char*, int);
214 _CRTIMP int __cdecl __MINGW_NOTHROW     stat (const char*, struct stat*);
215
216 #endif  /* Not _NO_OLDNAMES */
217
218 #if defined (__MSVCRT__)
219 #if __MSVCRT_VERSION__ < 0x0800
220 _CRTIMP int __cdecl __MINGW_NOTHROW  _fstati64(int, struct _stati64 *);
221 _CRTIMP int __cdecl __MINGW_NOTHROW  _stati64(const char *, struct _stati64 *);
222 #endif
223 /* These require newer versions of msvcrt.dll (6.10 or higher).  */
224 #if __MSVCRT_VERSION__ >= 0x0601
225 _CRTIMP int __cdecl __MINGW_NOTHROW _fstat64 (int, struct __stat64*);
226 _CRTIMP int __cdecl __MINGW_NOTHROW _stat64 (const char*, struct __stat64*);
227 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
228 #if __MSVCRT_VERSION__ >= 0x0800
229 _CRTIMP int __cdecl __MINGW_NOTHROW     _fstat32 (int, struct __stat32*);
230 _CRTIMP int __cdecl __MINGW_NOTHROW     _stat32 (const char*, struct __stat32*);
231 _CRTIMP int __cdecl __MINGW_NOTHROW     _fstat32i64 (int, struct _stat32i64*);
232 _CRTIMP int __cdecl __MINGW_NOTHROW     _fstat64i32 (int, struct _stat64i32*);
233 _CRTIMP int __cdecl __MINGW_NOTHROW     _stat32i64 (const char*, struct _stat32i64*);
234 _CRTIMP int __cdecl __MINGW_NOTHROW     _stat64i32 (const char*, struct _stat64i32*);
235 #ifndef _USE_32BIT_TIME_T
236 _CRTALIAS int __cdecl __MINGW_NOTHROW   _fstat (int _v1, struct _stat* _v2)              { return(_fstat64i32 (_v1,(struct _stat64i32*)_v2)); }
237 _CRTALIAS int __cdecl __MINGW_NOTHROW   _stat (const char* _v1, struct _stat* _v2)       { return(_stat64i32  (_v1,(struct _stat64i32*)_v2)); }
238 _CRTALIAS int __cdecl __MINGW_NOTHROW   _fstati64 (int _v1, struct _stati64* _v2)        { return(_fstat64 (_v1,(struct __stat64*)_v2)); }
239 _CRTALIAS int __cdecl __MINGW_NOTHROW   _stati64 (const char* _v1, struct _stati64* _v2) { return(_stat64  (_v1,(struct __stat64*)_v2)); }
240 #else
241 _CRTALIAS int __cdecl __MINGW_NOTHROW   _fstat (int _v1, struct _stat* _v2)              { return(_fstat32 (_v1,(struct __stat32*)_v2)); }
242 _CRTALIAS int __cdecl __MINGW_NOTHROW   _stat (const char* _v1, struct _stat* _v2)       { return(_stat32  (_v1,(struct __stat32*)_v2)); }
243 _CRTALIAS int __cdecl __MINGW_NOTHROW   _fstati64 (int _v1, struct _stati64* _v2)        { return(_fstat32i64 (_v1,(struct _stat32i64*)_v2)); }
244 _CRTALIAS int __cdecl __MINGW_NOTHROW   _stati64 (const char* _v1, struct _stati64* _v2) { return(_stat32i64  (_v1,(struct _stat32i64*)_v2)); }
245 #endif /* !_USE_32BIT_TIME_T */
246 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
247
248
249 #if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
250 #if __MSVCRT_VERSION__ < 0x0800
251 _CRTIMP int __cdecl __MINGW_NOTHROW     _wstat(const wchar_t*, struct _stat*);
252 _CRTIMP int __cdecl __MINGW_NOTHROW     _wstati64 (const wchar_t*, struct _stati64*);
253 #endif
254 #if __MSVCRT_VERSION__ >= 0x0601
255 _CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct __stat64*);
256 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
257 #if __MSVCRT_VERSION__ >= 0x0800
258 _CRTIMP int __cdecl __MINGW_NOTHROW     _wstat32 (const wchar_t*, struct __stat32*);
259 _CRTIMP int __cdecl __MINGW_NOTHROW     _wstat32i64 (const wchar_t*, struct _stat32i64*);
260 _CRTIMP int __cdecl __MINGW_NOTHROW     _wstat64i32 (const wchar_t*, struct _stat64i32*);
261 #ifndef _USE_32BIT_TIME_T
262 _CRTALIAS int __cdecl __MINGW_NOTHROW   _wstat (const wchar_t* _v1, struct _stat* _v2)       { return(_wstat64i32 (_v1,(struct _stat64i32*)_v2)); }
263 _CRTALIAS int __cdecl __MINGW_NOTHROW   _wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat64 (_v1,(struct __stat64*)_v2)); }
264 #else
265 _CRTALIAS int __cdecl __MINGW_NOTHROW   _wstat (const wchar_t* _v1, struct _stat* _v2)       { return(_wstat32 (_v1,(struct __stat32*)_v2)); }
266 _CRTALIAS int __cdecl __MINGW_NOTHROW   _wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat32i64 (_v1,(struct _stat32i64*)_v2)); }
267 #endif /* !_USE_32BIT_TIME_T */
268 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
269 #define _WSTAT_DEFINED
270 #endif /* _WSTAT_DEFIND */
271 #endif /* __MSVCRT__ */
272
273 #ifdef  __cplusplus
274 }
275 #endif
276
277 #endif  /* Not RC_INVOKED */
278
279 #endif  /* Not _STAT_H_ */