1 /* sys/stat.h supplied with MSVCRT uses too narrow data types for
2 inode and user/group id, so we replace them with our own.
4 Copyright (C) 2008-2017 Free Software Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or (at
11 your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 #ifndef INC_SYS_STAT_H_
22 #define INC_SYS_STAT_H_
28 /* Only MinGW 3.13 and later has __MINGW_NOTHROW. */
29 #ifndef __MINGW_NOTHROW
30 # define __MINGW_NOTHROW
33 /* Prevent the MinGW stat.h header from being included, ever. */
41 #include <sys/types.h>
46 #define S_IFREG 0x8000
47 #define S_IFDIR 0x4000
48 #define S_IFBLK 0x3000
49 #define S_IFCHR 0x2000
50 #define S_IFIFO 0x1000
51 #define S_IFLNK 0x0800
53 #define S_IREAD 0x0100
54 #define S_IWRITE 0x0080
55 #define S_IEXEC 0x0040
57 #define S_IRUSR S_IREAD
58 #define S_IWUSR S_IWRITE
59 #define S_IXUSR S_IEXEC
60 #define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC)
62 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
63 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
64 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
65 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
66 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
67 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
69 /* These don't exist on Windows, but lib/filemode.c wants them. */
73 #define S_IRGRP (S_IRUSR >> 3)
74 #define S_IROTH (S_IRUSR >> 6)
75 #define S_IWGRP (S_IWUSR >> 3)
76 #define S_IWOTH (S_IWUSR >> 6)
77 #define S_IXGRP (S_IXUSR >> 3)
78 #define S_IXOTH (S_IXUSR >> 6)
89 #define S_TYPEISMQ(p) 0
90 #define S_TYPEISSEM(p) 0
91 #define S_TYPEISSHM(p) 0
92 #define S_TYPEISTMO(p) 0
94 #define UTIME_NOW (-1)
95 #define UTIME_OMIT (-2)
98 unsigned __int64 st_ino
; /* ino_t in sys/types.h is too narrow */
100 unsigned short st_mode
;
102 unsigned st_uid
; /* Vista's TrustedInstaller has a very large RID */
104 unsigned __int64 st_size
;
113 /* These are here to avoid compiler warnings when using wchar.h. */
116 _dev_t st_dev
; /* Equivalent to drive number 0=A 1=B ... */
117 _ino_t st_ino
; /* Always zero ? */
118 _mode_t st_mode
; /* See above constants */
119 short st_nlink
; /* Number of links. */
120 short st_uid
; /* User: Maybe significant on NT ? */
121 short st_gid
; /* Group: Ditto */
122 _dev_t st_rdev
; /* Seems useless (not even filled in) */
123 _off_t st_size
; /* File size in bytes */
124 time_t st_atime
; /* Accessed date (always 00:00 hrs local
126 time_t st_mtime
; /* Modified time */
127 time_t st_ctime
; /* Creation time */
130 #if defined (__MSVCRT__)
146 /* Internal variable for asking 'stat'/'lstat' to produce accurate
147 info about owner and group of files. */
148 extern int w32_stat_get_owner_group
;
150 /* Prevent redefinition by other headers, e.g. wchar.h. */
151 #define _STAT_DEFINED
152 /* This prevents definition in MinGW's wchar.h of inline functions
153 that use struct _stat64i32 etc., which we don't define and don't
154 support in our implementation of 'stat' and 'fstat'. If we don't
155 prevent definition of those inline functions, any program (e.g.,
156 test programs run by configure) that includes both wchar.h and
157 sys/stat.h will fail to compile. */
158 #define _WSTAT_DEFINED
160 int __cdecl __MINGW_NOTHROW
fstat (int, struct stat
*);
161 int __cdecl __MINGW_NOTHROW
stat (const char*, struct stat
*);
162 int __cdecl __MINGW_NOTHROW
lstat (const char*, struct stat
*);
163 int __cdecl __MINGW_NOTHROW
fstatat (int, char const *,
165 int __cdecl __MINGW_NOTHROW
chmod (const char*, int);
167 #endif /* INC_SYS_STAT_H_ */