Commit | Line | Data |
---|---|---|
87c24bb7 EZ |
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. | |
3 | ||
ba318903 | 4 | Copyright (C) 2008-2014 Free Software Foundation, Inc. |
87c24bb7 EZ |
5 | |
6 | This file is part of GNU Emacs. | |
7 | ||
eef0be9e | 8 | GNU Emacs is free software: you can redistribute it and/or modify |
87c24bb7 | 9 | it under the terms of the GNU General Public License as published by |
eef0be9e GM |
10 | the Free Software Foundation, either version 3 of the License, or |
11 | (at your option) any later version. | |
87c24bb7 EZ |
12 | |
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. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
eef0be9e | 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
40beb147 EZ |
20 | |
21 | #ifndef INC_SYS_STAT_H_ | |
22 | #define INC_SYS_STAT_H_ | |
23 | ||
24 | #ifdef __MINGW32__ | |
25 | # include <_mingw.h> | |
87c24bb7 EZ |
26 | #endif |
27 | ||
28 | /* Only MinGW 3.13 and later has __MINGW_NOTHROW. */ | |
29 | #ifndef __MINGW_NOTHROW | |
40beb147 EZ |
30 | # define __MINGW_NOTHROW |
31 | #endif | |
32 | ||
33 | #include <sys/types.h> | |
34 | #include <time.h> | |
35 | ||
6dad7178 | 36 | #define S_IFMT 0xF800 |
40beb147 EZ |
37 | |
38 | #define S_IFREG 0x8000 | |
39 | #define S_IFDIR 0x4000 | |
40 | #define S_IFBLK 0x3000 | |
41 | #define S_IFCHR 0x2000 | |
42 | #define S_IFIFO 0x1000 | |
6dad7178 | 43 | #define S_IFLNK 0x0800 |
40beb147 EZ |
44 | |
45 | #define S_IREAD 0x0100 | |
46 | #define S_IWRITE 0x0080 | |
47 | #define S_IEXEC 0x0040 | |
48 | ||
49 | #define S_IRUSR S_IREAD | |
50 | #define S_IWUSR S_IWRITE | |
51 | #define S_IXUSR S_IEXEC | |
52 | #define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC) | |
53 | ||
54 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
55 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) | |
56 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) | |
57 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) | |
58 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) | |
6dad7178 | 59 | #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) |
40beb147 | 60 | |
25c51af3 EZ |
61 | /* These don't exist on Windows, but lib/filemode.c wants them. */ |
62 | #define S_ISUID 0 | |
63 | #define S_ISGID 0 | |
64 | #define S_ISVTX 0 | |
65 | #define S_IRGRP (S_IRUSR >> 3) | |
66 | #define S_IROTH (S_IRUSR >> 6) | |
67 | #define S_IWGRP (S_IWUSR >> 3) | |
68 | #define S_IWOTH (S_IWUSR >> 6) | |
69 | #define S_IXGRP (S_IXUSR >> 3) | |
70 | #define S_IXOTH (S_IXUSR >> 6) | |
71 | ||
72 | #define S_ISSOCK(m) 0 | |
25c51af3 EZ |
73 | #define S_ISCTG(p) 0 |
74 | #define S_ISDOOR(m) 0 | |
75 | #define S_ISMPB(m) 0 | |
76 | #define S_ISMPC(m) 0 | |
c1860cdc | 77 | #define S_ISMPX(m) 0 |
25c51af3 EZ |
78 | #define S_ISNWK(m) 0 |
79 | #define S_ISPORT(m) 0 | |
80 | #define S_ISWHT(m) 0 | |
81 | #define S_TYPEISMQ(p) 0 | |
82 | #define S_TYPEISSEM(p) 0 | |
83 | #define S_TYPEISSHM(p) 0 | |
84 | #define S_TYPEISTMO(p) 0 | |
85 | ||
fff1aa4e EZ |
86 | #define UTIME_NOW (-1) |
87 | #define UTIME_OMIT (-2) | |
88 | ||
40beb147 | 89 | struct stat { |
40beb147 | 90 | unsigned __int64 st_ino; /* ino_t in sys/types.h is too narrow */ |
71e41ffb | 91 | dev_t st_dev; |
40beb147 EZ |
92 | unsigned short st_mode; |
93 | short st_nlink; | |
22749e9a EZ |
94 | unsigned st_uid; /* Vista's TrustedInstaller has a very large RID */ |
95 | unsigned st_gid; | |
71e41ffb | 96 | unsigned __int64 st_size; |
40beb147 | 97 | dev_t st_rdev; |
40beb147 EZ |
98 | time_t st_atime; |
99 | time_t st_mtime; | |
100 | time_t st_ctime; | |
71e41ffb EZ |
101 | char st_uname[260]; |
102 | char st_gname[260]; | |
40beb147 EZ |
103 | }; |
104 | ||
86e93460 EZ |
105 | /* These are here to avoid compiler warnings when using wchar.h. */ |
106 | struct _stat | |
107 | { | |
108 | _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ | |
109 | _ino_t st_ino; /* Always zero ? */ | |
110 | _mode_t st_mode; /* See above constants */ | |
111 | short st_nlink; /* Number of links. */ | |
112 | short st_uid; /* User: Maybe significant on NT ? */ | |
113 | short st_gid; /* Group: Ditto */ | |
114 | _dev_t st_rdev; /* Seems useless (not even filled in) */ | |
115 | _off_t st_size; /* File size in bytes */ | |
116 | time_t st_atime; /* Accessed date (always 00:00 hrs local | |
117 | * on FAT) */ | |
118 | time_t st_mtime; /* Modified time */ | |
119 | time_t st_ctime; /* Creation time */ | |
120 | }; | |
121 | ||
122 | #if defined (__MSVCRT__) | |
123 | struct _stati64 { | |
124 | _dev_t st_dev; | |
125 | _ino_t st_ino; | |
126 | _mode_t st_mode; | |
127 | short st_nlink; | |
128 | short st_uid; | |
129 | short st_gid; | |
130 | _dev_t st_rdev; | |
131 | __int64 st_size; | |
132 | time_t st_atime; | |
133 | time_t st_mtime; | |
134 | time_t st_ctime; | |
135 | }; | |
136 | #endif | |
137 | ||
5c207910 EZ |
138 | /* Internal variable for asking 'stat'/'lstat' to produce accurate |
139 | info about owner and group of files. */ | |
140 | extern int w32_stat_get_owner_group; | |
141 | ||
e0aeebda EZ |
142 | /* Prevent redefinition by other headers, e.g. wchar.h. */ |
143 | #define _STAT_DEFINED | |
f0b5cd89 CB |
144 | /* This prevents definition in MinGW's wchar.h of inline functions |
145 | that use struct _stat64i32 etc., which we don't define and don't | |
146 | support in our implementation of 'stat' and 'fstat'. If we don't | |
147 | prevent definition of those inline functions, any program (e.g., | |
148 | test programs run by configure) that includes both wchar.h and | |
149 | sys/stat.h will fail to compile. */ | |
150 | #define _WSTAT_DEFINED | |
e0aeebda | 151 | |
b88b62de EZ |
152 | int __cdecl __MINGW_NOTHROW fstat (int, struct stat*); |
153 | int __cdecl __MINGW_NOTHROW stat (const char*, struct stat*); | |
154 | int __cdecl __MINGW_NOTHROW lstat (const char*, struct stat*); | |
155 | int __cdecl __MINGW_NOTHROW fstatat (int, char const *, | |
8654f9d7 | 156 | struct stat *, int); |
a18d7de6 | 157 | int __cdecl __MINGW_NOTHROW chmod (const char*, int); |
25c51af3 | 158 | |
40beb147 | 159 | #endif /* INC_SYS_STAT_H_ */ |