Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[aae1b3]: include / sys / stat.h Maximize Restore History

Download this file

stat.h    378 lines (341 with data), 11.4 kB

  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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/**
* @file stat.h
* Copyright 2012, 2013 MinGW.org project
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _STAT_H_
#define _STAT_H_
#pragma GCC system_header
#include <_mingw.h>
#define __need_size_t
#define __need_wchar_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#include <sys/types.h>
/*
* Constants for the stat st_mode member.
*/
#define _S_IFIFO 0x1000 /* FIFO */
#define _S_IFCHR 0x2000 /* Character */
#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
#define _S_IFDIR 0x4000 /* Directory */
#define _S_IFREG 0x8000 /* Regular */
#define _S_IFMT 0xF000 /* File type mask */
#define _S_IEXEC 0x0040
#define _S_IWRITE 0x0080
#define _S_IREAD 0x0100
#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
#define _S_IXUSR _S_IEXEC
#define _S_IWUSR _S_IWRITE
#define _S_IRUSR _S_IREAD
#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
#define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
#define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
#define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#ifndef _NO_OLDNAMES
#define S_IFIFO _S_IFIFO
#define S_IFCHR _S_IFCHR
#define S_IFBLK _S_IFBLK
#define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG
#define S_IFMT _S_IFMT
#define S_IEXEC _S_IEXEC
#define S_IWRITE _S_IWRITE
#define S_IREAD _S_IREAD
#define S_IRWXU _S_IRWXU
#define S_IXUSR _S_IXUSR
#define S_IWUSR _S_IWUSR
#define S_IRUSR _S_IRUSR
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif /* Not _NO_OLDNAMES */
#ifndef RC_INVOKED
#ifndef _STAT_DEFINED
/*
* The structure manipulated and returned by stat and fstat.
*
* NOTE: If called on a directory the values in the time fields are not only
* invalid, they will cause localtime et. al. to return NULL. And calling
* asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
*/
struct _stat32
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t st_size; /* File size in bytes */
__time32_t st_atime; /* Accessed date (always 00:00 hrs local
* on FAT) */
__time32_t st_mtime; /* Modified time */
__time32_t st_ctime; /* Creation time */
};
#ifndef __STRICT_ANSI__
struct stat {
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t st_size; /* File size in bytes */
time_t st_atime; /* Accessed date (always 00:00 hrs local
* on FAT) */
time_t st_mtime; /* Modified time */
time_t st_ctime; /* Creation time */
};
#endif /* __STRICT_ANSI__ */
struct _stat64 {
dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
ino_t st_ino; /* Always zero ? */
mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
dev_t st_rdev; /* Seems useless (not even filled in) */
_off64_t st_size; /* File size in bytes */
__time64_t st_atime; /* Accessed date (always 00:00 hrs local
* on FAT) */
__time64_t st_mtime; /* Modified time */
__time64_t st_ctime; /* Creation time */
};
struct _stat32i64 {
_dev_t st_dev;
_ino_t st_ino;
_mode_t st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off64_t st_size;
__time32_t st_atime;
__time32_t st_mtime;
__time32_t st_ctime;
};
struct _stat64i32 {
_dev_t st_dev;
_ino_t st_ino;
_mode_t 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;
};
#ifdef __cplusplus
extern "C" {
#endif
/* _stat32 does not exist in MSVCRT.DLL */
_CRTIMP int __cdecl __MINGW_NOTHROW _stat (const char*, struct _stat32*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _stat32 (const char* _v1, struct _stat32* _v2) {
return _stat(_v1, _v2);
}
_CRTIMP int __cdecl __MINGW_NOTHROW _stat64 (const char*, struct _stat64*);
int __cdecl __MINGW_NOTHROW _stat32i64 (const char*, struct _stat32i64*);
int __cdecl __MINGW_NOTHROW _stat64i32 (const char*, struct _stat64i32*);
/* _fstat32 does not exist in MSVCRT.DLL */
_CRTIMP int __cdecl __MINGW_NOTHROW _fstat (int, struct _stat32*);
_CRTALIAS int __cdecl __MINGW_NOTHROW _fstat32 (int _v1, struct _stat32* _v2) {
return _fstat(_v1, _v2);
}
_CRTIMP int __cdecl __MINGW_NOTHROW _fstat64 (int, struct _stat64*);
int __cdecl __MINGW_NOTHROW _fstat32i64 (int, struct _stat32i64*);
int __cdecl __MINGW_NOTHROW _fstat64i32 (int, struct _stat64i32*);
#include <string.h> /* Need memset declaration */
__CRT_MAYBE_INLINE int __cdecl _fstat64i32(int desc, struct _stat64i32 *_stat) {
struct _stat64 st;
int ret = _fstat64(desc, &st);
if (ret == -1) {
memset(_stat, 0, sizeof(struct _stat64i32));
return -1;
}
_stat->st_dev = st.st_dev;
_stat->st_ino = st.st_ino;
_stat->st_mode = st.st_mode;
_stat->st_nlink = st.st_nlink;
_stat->st_uid = st.st_uid;
_stat->st_gid = st.st_gid;
_stat->st_rdev = st.st_rdev;
_stat->st_size = (_off_t) st.st_size;
_stat->st_atime = st.st_atime;
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
}
__CRT_MAYBE_INLINE int __cdecl _fstat32i64(int desc, struct _stat32i64 *_stat)
{
struct _stat32 st;
int ret = _fstat32(desc, &st);
if (ret == -1) {
memset(_stat, 0, sizeof(struct _stat32i64));
return -1;
}
_stat->st_dev = st.st_dev;
_stat->st_ino = st.st_ino;
_stat->st_mode = st.st_mode;
_stat->st_nlink = st.st_nlink;
_stat->st_uid = st.st_uid;
_stat->st_gid = st.st_gid;
_stat->st_rdev = st.st_rdev;
_stat->st_size = (_off_t) st.st_size;
_stat->st_atime = st.st_atime;
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
}
__CRT_MAYBE_INLINE int __cdecl _stat64i32(const char *fname, struct _stat64i32 *_stat)
{
struct _stat64 st;
int ret = _stat64(fname, &st);
if (ret == -1) {
memset(_stat, 0, sizeof(struct _stat64i32));
return -1;
}
_stat->st_dev = st.st_dev;
_stat->st_ino = st.st_ino;
_stat->st_mode = st.st_mode;
_stat->st_nlink = st.st_nlink;
_stat->st_uid = st.st_uid;
_stat->st_gid = st.st_gid;
_stat->st_rdev = st.st_rdev;
_stat->st_size = (_off_t) st.st_size;
_stat->st_atime = st.st_atime;
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
}
__CRT_MAYBE_INLINE int __cdecl _stat32i64(const char *fname, struct _stat32i64 *_stat)
{
struct _stat32 st;
int ret = _stat32(fname, &st);
if (ret == -1) {
memset(_stat, 0, sizeof(struct _stat32i64));
return -1;
}
_stat->st_dev = st.st_dev;
_stat->st_ino = st.st_ino;
_stat->st_mode = st.st_mode;
_stat->st_nlink = st.st_nlink;
_stat->st_uid = st.st_uid;
_stat->st_gid = st.st_gid;
_stat->st_rdev = st.st_rdev;
_stat->st_size = (_off_t) st.st_size;
_stat->st_atime = st.st_atime;
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
}
#define __stat64 _stat64
#if defined(_USE_32BIT_TIME_T)
#define _fstat _fstat32
#define _fstati64 _fstat32i64
#define _stat _stat32
#define _stati64 _stat32i64
#else /* !_USE_32BIT_TIME_T */
#define _fstat _fstat64i32
#define _fstati64 _fstat64
#define _stat _stat64i32
#define _stati64 _stat64
#endif /* _USE_32BIT_TIME_T */
#define _STAT_DEFINED
#endif /* _STAT_DEFINED */
#if !defined(_NO_OLDNAMES) && !defined(__STRICT_ANSI__)
#define stat _stat
#define fstat _fstat
#endif /* !defined(_NO_OLDNAMES) && !defined(__STRICT_ANSI__) */
#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
/* _wstat32 does not exist in MSVCRT.DLL */
_CRTALIAS int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t* _v1, struct _stat32* _v2) {
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat32*);
return _wstat(_v1, _v2);
}
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct _stat64*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32i64 (const wchar_t*, struct _stat32i64*);
int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
#include <string.h> /* Need memset declaration */
__CRT_MAYBE_INLINE int __cdecl _wstat64i32(const wchar_t *fname, struct _stat64i32 *_stat)
{
struct _stat64 st;
int ret = _wstat64(fname, &st);
if (ret == -1) {
memset(_stat, 0, sizeof(struct _stat64i32));
return -1;
}
_stat->st_dev = st.st_dev;
_stat->st_ino = st.st_ino;
_stat->st_mode = st.st_mode;
_stat->st_nlink = st.st_nlink;
_stat->st_uid = st.st_uid;
_stat->st_gid = st.st_gid;
_stat->st_rdev = st.st_rdev;
_stat->st_size = (_off_t) st.st_size;
_stat->st_atime = st.st_atime;
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
}
__CRT_MAYBE_INLINE int __cdecl _wstat32i64(const wchar_t *fname, struct _stat32i64 *_stat)
{
struct _stat32 st;
int ret = _wstat32(fname, &st);
if (ret == -1) {
memset(_stat, 0, sizeof(struct _stat32i64));
return -1;
}
_stat->st_dev = st.st_dev;
_stat->st_ino = st.st_ino;
_stat->st_mode = st.st_mode;
_stat->st_nlink = st.st_nlink;
_stat->st_uid = st.st_uid;
_stat->st_gid = st.st_gid;
_stat->st_rdev = st.st_rdev;
_stat->st_size = (_off_t) st.st_size;
_stat->st_atime = st.st_atime;
_stat->st_mtime = st.st_mtime;
_stat->st_ctime = st.st_ctime;
return ret;
}
#if defined(_USE_32BIT_TIME_T)
#define _wstat _wstat32
#define _wstati64 _wstat32i64
#else /* !_USE_32BIT_TIME_T */
#define _wstat _wstat64i32
#define _wstati64 _wstat64
#endif /* _USE_32BIT_TIME_T */
#define _WSTAT_DEFINED
#endif /* _WSTAT_DEFIND */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _STAT_H_ */