stat.h 4.15 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*
 * _stat() definitions
 *
 * Derived from the mingw header written by Colin Peters.
 * Modified for Wine use by Jon Griffiths and Francois Gouget.
 * This file is in the public domain.
 */
#ifndef __WINE_SYS_STAT_H
#define __WINE_SYS_STAT_H
10

11
#include <crtdefs.h>
12
#include <sys/types.h>
13

14
#include <pshpack8.h>
15

16 17 18
#ifndef _DEV_T_DEFINED
typedef unsigned int _dev_t;
#define _DEV_T_DEFINED
19 20
#endif

21 22 23
#ifndef _INO_T_DEFINED
typedef unsigned short _ino_t;
#define _INO_T_DEFINED
24 25
#endif

26 27 28
#ifndef _OFF_T_DEFINED
typedef int _off_t;
#define _OFF_T_DEFINED
29
#endif
30

31 32 33 34 35 36 37 38 39 40
#ifndef DECLSPEC_ALIGN
# if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
#  define DECLSPEC_ALIGN(x) __declspec(align(x))
# elif defined(__GNUC__)
#  define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
# else
#  define DECLSPEC_ALIGN(x)
# endif
#endif

41 42 43 44 45 46 47 48 49
#define _S_IEXEC  0x0040
#define _S_IWRITE 0x0080
#define _S_IREAD  0x0100
#define _S_IFIFO  0x1000
#define _S_IFCHR  0x2000
#define _S_IFDIR  0x4000
#define _S_IFREG  0x8000
#define _S_IFMT   0xF000

50 51 52 53
/* for FreeBSD */
#undef st_atime
#undef st_ctime
#undef st_mtime
54

55 56
#ifndef _STAT_DEFINED
#define _STAT_DEFINED
57

58 59 60
struct _stat {
  _dev_t st_dev;
  _ino_t st_ino;
61 62 63 64
  unsigned short st_mode;
  short          st_nlink;
  short          st_uid;
  short          st_gid;
65 66 67 68 69
  _dev_t st_rdev;
  _off_t st_size;
  time_t st_atime;
  time_t st_mtime;
  time_t st_ctime;
70 71
};

72 73 74
struct stat {
  _dev_t st_dev;
  _ino_t st_ino;
75 76 77 78
  unsigned short st_mode;
  short          st_nlink;
  short          st_uid;
  short          st_gid;
79 80 81 82 83
  _dev_t st_rdev;
  _off_t st_size;
  time_t st_atime;
  time_t st_mtime;
  time_t st_ctime;
84 85
};

86 87 88 89 90 91 92 93 94 95 96 97 98 99
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;
};

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
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 DECLSPEC_ALIGN(8) st_size;
  time_t st_atime;
  time_t st_mtime;
  time_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;
};

128 129 130
struct _stati64 {
  _dev_t st_dev;
  _ino_t st_ino;
131 132 133 134
  unsigned short st_mode;
  short          st_nlink;
  short          st_uid;
  short          st_gid;
135
  _dev_t st_rdev;
136
  __int64 DECLSPEC_ALIGN(8) st_size;
137 138 139
  time_t st_atime;
  time_t st_mtime;
  time_t st_ctime;
140
};
141 142 143 144 145 146 147 148 149 150 151 152 153 154

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 DECLSPEC_ALIGN(8) st_size;
  __time64_t     st_atime;
  __time64_t     st_mtime;
  __time64_t     st_ctime;
};
155
#endif /* _STAT_DEFINED */
156 157 158 159 160

#ifdef __cplusplus
extern "C" {
#endif

161 162
int __cdecl _fstat(int,struct _stat*);
int __cdecl _stat(const char*,struct _stat*);
163 164
int __cdecl _fstat32(int, struct _stat32*);
int __cdecl _stat32(const char*, struct _stat32*);
165 166 167 168 169
int __cdecl _fstati64(int,struct _stati64*);
int __cdecl _stati64(const char*,struct _stati64*);
int __cdecl _fstat64(int,struct _stat64*);
int __cdecl _stat64(const char*,struct _stat64*);
int __cdecl _umask(int);
170

171 172
#ifndef _WSTAT_DEFINED
#define _WSTAT_DEFINED
173
int __cdecl _wstat(const wchar_t*,struct _stat*);
174
int __cdecl _wstat32(const wchar_t*, struct _stat32*);
175 176
int __cdecl _wstati64(const wchar_t*,struct _stati64*);
int __cdecl _wstat64(const wchar_t*,struct _stat64*);
177
#endif /* _WSTAT_DEFINED */
178 179 180 181 182 183 184 185 186 187 188 189 190 191

#ifdef __cplusplus
}
#endif


#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

192 193
static inline int fstat(int fd, struct stat* ptr) { return _fstat(fd, (struct _stat*)ptr); }
static inline int stat(const char* path, struct stat* ptr) { return _stat(path, (struct _stat*)ptr); }
194
#ifndef _UMASK_DEFINED
195
static inline int umask(int fd) { return _umask(fd); }
196
#define _UMASK_DEFINED
197
#endif
198

199 200
#include <poppack.h>

201
#endif /* __WINE_SYS_STAT_H */