update for HEAD-2003021201
[reactos.git] / include / msvcrt / sys / stat.h
1 /*
2  * stat.h
3  *
4  * Symbolic constants for opening and creating files, also stat, fstat and
5  * chmod functions.
6  *
7  * This file is part of the Mingw32 package.
8  *
9  * Contributors:
10  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11  *
12  *  THIS SOFTWARE IS NOT COPYRIGHTED
13  *
14  *  This source code is offered for use in the public domain. You may
15  *  use, modify or distribute it freely.
16  *
17  *  This code is distributed in the hope that it will be useful but
18  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19  *  DISCLAIMED. This includes but is not limited to warranties of
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * $Revision$
23  * $Author$
24  * $Date$
25  *
26  */
27
28 #ifndef __STRICT_ANSI__
29
30 #ifndef _STAT_H_
31 #define _STAT_H_
32
33 #include <msvcrt/sys/types.h>
34
35
36 #ifndef _WCHAR_T_
37 #define _WCHAR_T_
38 #define _WCHAR_T
39 #define _WCHAR_T_DEFINED
40 #ifndef __WCHAR_TYPE__
41 #define __WCHAR_TYPE__      short unsigned int
42 #endif
43 #ifndef __cplusplus
44 typedef __WCHAR_TYPE__      wchar_t;
45 #endif  /* C++ */
46 #endif  /* wchar_t not already defined */
47
48
49 /*
50  * Constants for the stat st_mode member.
51  */
52 #define S_IFIFO     0x1000  /* FIFO */
53 #define S_IFCHR     0x2000  /* Character */
54 #define S_IFBLK     0x3000  /* Block */
55 #define S_IFDIR     0x4000  /* Directory */
56 #define S_IFREG     0x8000  /* Regular */
57
58 #define S_IFMT      0xF000  /* File type mask */
59
60 #define S_IEXEC     0x0040
61 #define S_IWRITE    0x0080
62 #define S_IREAD     0x0100
63
64 #define S_ISDIR(m)  ((m) & S_IFDIR)
65 #define S_ISFIFO(m) ((m) & S_IFIFO)
66 #define S_ISCHR(m)  ((m) & S_IFCHR)
67 #define S_ISBLK(m)  ((m) & S_IFBLK)
68 #define S_ISREG(m)  ((m) & S_IFREG)
69
70 #define S_IRWXU     (S_IREAD | S_IWRITE | S_IEXEC)
71 #define S_IXUSR     S_IEXEC
72 #define S_IWUSR     S_IWRITE
73 #define S_IRUSR     S_IREAD
74
75 #define _S_IEXEC    S_IEXEC
76 #define _S_IREAD    S_IREAD
77 #define _S_IWRITE   S_IWRITE
78
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 #ifdef _MSVCRT_LIB_
89     long    st_dev;     /* Equivalent to drive number 0=A 1=B ... */
90 #else
91     short   st_dev;     /* Equivalent to drive number 0=A 1=B ... */
92     short   st_padding; /* Pad structure to equal msvcrt version req */
93 #endif
94     short   st_ino;     /* Always zero ? */
95     short   st_mode;    /* See above constants */
96     short   st_nlink;   /* Number of links. */
97     int     st_uid;     /* User: Maybe significant on NT ? */
98     short   st_gid;     /* Group: Ditto */
99     short   st_rdev;    /* Seems useless (not even filled in) */
100     long    st_size;    /* File size in bytes */
101     time_t  st_atime;   /* Accessed date (always 00:00 hrs local on FAT) */
102     time_t  st_mtime;   /* Modified time */
103     time_t  st_ctime;   /* Creation time */
104 };
105
106
107 struct _stati64
108 {
109     short   st_dev;     /* Equivalent to drive number 0=A 1=B ... */
110     short   st_ino;     /* Always zero ? */
111     short   st_mode;    /* See above constants */
112     short   st_nlink;   /* Number of links. */
113     int     st_uid;     /* User: Maybe significant on NT ? */
114     short   st_gid;     /* Group: Ditto */
115     short   st_rdev;    /* Seems useless (not even filled in) */
116     __int64 st_size;    /* File size in bytes */
117     time_t  st_atime;   /* Accessed date (always 00:00 hrs local on FAT) */
118     time_t  st_mtime;   /* Modified time */
119     time_t  st_ctime;   /* Creation time */
120 };
121
122 #ifdef  __cplusplus
123 extern "C" {
124 #endif
125
126 int _fstat(int, struct stat*);
127 int _stat(const char*, struct stat*);
128
129 __int64 _fstati64(int nFileNo, struct _stati64* pstat);
130 __int64 _stati64(const char* szPath, struct _stati64* pstat);
131 int _wstat(const wchar_t* szPath, struct stat* pstat);
132 __int64 _wstati64(const wchar_t* szPath, struct _stati64* pstat);
133
134
135 #ifndef _NO_OLDNAMES
136
137 #define fstat(nFileNo, pstat)   _fstat(nFileNo, pstat)
138 #define stat(szPath,pstat)  _stat(szPath,pstat)
139
140 #endif  /* Not _NO_OLDNAMES */
141
142
143 #ifdef  __cplusplus
144 }
145 #endif
146
147 #endif  /* Not _STAT_H_ */
148
149 #endif  /* Not __STRICT_ANSI__ */