:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / include / crtdll / 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  *  DISCLAMED. 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 <crtdll/sys/types.h>
34
35 #ifdef  __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40  * Constants for the stat st_mode member.
41  */
42 #define S_IFIFO         0x1000  /* FIFO */
43 #define S_IFCHR         0x2000  /* Character */
44 #define S_IFBLK         0x3000  /* Block */
45 #define S_IFDIR         0x4000  /* Directory */
46 #define S_IFREG         0x8000  /* Regular */
47
48 #define S_IFMT          0xF000  /* File type mask */
49
50 #define S_IEXEC         0x0040
51 #define S_IWRITE        0x0080
52 #define S_IREAD         0x0100
53
54 #define S_ISDIR(m)      ((m) & S_IFDIR)
55 #define S_ISFIFO(m)     ((m) & S_IFIFO)
56 #define S_ISCHR(m)      ((m) & S_IFCHR)
57 #define S_ISBLK(m)      ((m) & S_IFBLK)
58 #define S_ISREG(m)      ((m) & S_IFREG)
59
60 #define S_IRWXU         (S_IREAD | S_IWRITE | S_IEXEC)
61 #define S_IXUSR         S_IEXEC
62 #define S_IWUSR         S_IWRITE
63 #define S_IRUSR         S_IREAD
64
65 #define _S_IEXEC        S_IEXEC
66 #define _S_IREAD        S_IREAD
67 #define _S_IWRITE       S_IWRITE
68
69 /*
70  * The structure manipulated and returned by stat and fstat.
71  *
72  * NOTE: If called on a directory the values in the time fields are not only
73  * invalid, they will cause localtime et. al. to return NULL. And calling
74  * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
75  */
76 struct stat
77 {
78         short   st_dev;         /* Equivalent to drive number 0=A 1=B ... */
79         short   st_ino;         /* Always zero ? */
80         short   st_mode;        /* See above constants */
81         short   st_nlink;       /* Number of links. */
82         int     st_uid;         /* User: Maybe significant on NT ? */
83         short   st_gid;         /* Group: Ditto */
84         short   st_rdev;        /* Seems useless (not even filled in) */
85         long    st_size;        /* File size in bytes */
86         time_t  st_atime;       /* Accessed date (always 00:00 hrs local
87                                  * on FAT) */
88         time_t  st_mtime;       /* Modified time */
89         time_t  st_ctime;       /* Creation time */
90 };
91
92
93 int     _fstat (int nFileNo, struct stat* pstat);
94 int     _chmod (const char* szPath, int nMode);
95 int     _stat (const char* szPath, struct stat* pstat);
96
97
98 #ifndef _NO_OLDNAMES
99
100 #define fstat(nFileNo, pstat)   _fstat(nFileNo, pstat)
101 #define chmod(szPath,nMode)     _chmod(szPath,nMode)
102 #define stat(szPath,pstat)      _stat(szPath,pstat)
103
104 #endif  /* Not _NO_OLDNAMES */
105
106
107 #ifdef  __cplusplus
108 }
109 #endif
110
111 #endif  /* Not _STAT_H_ */
112
113 #endif  /* Not __STRICT_ANSI__ */