stat.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 <[email protected]>
  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: 1.2 $
  23. * $Author: bellard $
  24. * $Date: 2005/04/17 13:14:29 $
  25. *
  26. */
  27. #ifndef __STRICT_ANSI__
  28. #ifndef _STAT_H_
  29. #define _STAT_H_
  30. /* All the headers include this file. */
  31. #include <_mingw.h>
  32. #define __need_size_t
  33. #define __need_wchar_t
  34. #ifndef RC_INVOKED
  35. #include <stddef.h>
  36. #endif /* Not RC_INVOKED */
  37. #include <sys/types.h>
  38. /*
  39. * Constants for the stat st_mode member.
  40. */
  41. #define _S_IFIFO 0x1000 /* FIFO */
  42. #define _S_IFCHR 0x2000 /* Character */
  43. #define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
  44. #define _S_IFDIR 0x4000 /* Directory */
  45. #define _S_IFREG 0x8000 /* Regular */
  46. #define _S_IFMT 0xF000 /* File type mask */
  47. #define _S_IEXEC 0x0040
  48. #define _S_IWRITE 0x0080
  49. #define _S_IREAD 0x0100
  50. #define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
  51. #define _S_IXUSR _S_IEXEC
  52. #define _S_IWUSR _S_IWRITE
  53. #define _S_IRUSR _S_IREAD
  54. #define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
  55. #define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
  56. #define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
  57. #define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
  58. #define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
  59. #ifndef _NO_OLDNAMES
  60. #define S_IFIFO _S_IFIFO
  61. #define S_IFCHR _S_IFCHR
  62. #define S_IFBLK _S_IFBLK
  63. #define S_IFDIR _S_IFDIR
  64. #define S_IFREG _S_IFREG
  65. #define S_IFMT _S_IFMT
  66. #define S_IEXEC _S_IEXEC
  67. #define S_IWRITE _S_IWRITE
  68. #define S_IREAD _S_IREAD
  69. #define S_IRWXU _S_IRWXU
  70. #define S_IXUSR _S_IXUSR
  71. #define S_IWUSR _S_IWUSR
  72. #define S_IRUSR _S_IRUSR
  73. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  74. #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  75. #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  76. #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  77. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  78. #endif /* Not _NO_OLDNAMES */
  79. #ifndef RC_INVOKED
  80. #ifndef _STAT_DEFINED
  81. /*
  82. * The structure manipulated and returned by stat and fstat.
  83. *
  84. * NOTE: If called on a directory the values in the time fields are not only
  85. * invalid, they will cause localtime et. al. to return NULL. And calling
  86. * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
  87. */
  88. struct _stat
  89. {
  90. _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
  91. _ino_t st_ino; /* Always zero ? */
  92. _mode_t st_mode; /* See above constants */
  93. short st_nlink; /* Number of links. */
  94. short st_uid; /* User: Maybe significant on NT ? */
  95. short st_gid; /* Group: Ditto */
  96. _dev_t st_rdev; /* Seems useless (not even filled in) */
  97. _off_t st_size; /* File size in bytes */
  98. time_t st_atime; /* Accessed date (always 00:00 hrs local
  99. * on FAT) */
  100. time_t st_mtime; /* Modified time */
  101. time_t st_ctime; /* Creation time */
  102. };
  103. struct stat
  104. {
  105. _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
  106. _ino_t st_ino; /* Always zero ? */
  107. _mode_t st_mode; /* See above constants */
  108. short st_nlink; /* Number of links. */
  109. short st_uid; /* User: Maybe significant on NT ? */
  110. short st_gid; /* Group: Ditto */
  111. _dev_t st_rdev; /* Seems useless (not even filled in) */
  112. _off_t st_size; /* File size in bytes */
  113. time_t st_atime; /* Accessed date (always 00:00 hrs local
  114. * on FAT) */
  115. time_t st_mtime; /* Modified time */
  116. time_t st_ctime; /* Creation time */
  117. };
  118. #if defined (__MSVCRT__)
  119. struct _stati64 {
  120. _dev_t st_dev;
  121. _ino_t st_ino;
  122. unsigned short st_mode;
  123. short st_nlink;
  124. short st_uid;
  125. short st_gid;
  126. _dev_t st_rdev;
  127. __int64 st_size;
  128. time_t st_atime;
  129. time_t st_mtime;
  130. time_t st_ctime;
  131. };
  132. #endif /* __MSVCRT__ */
  133. #define _STAT_DEFINED
  134. #endif /* _STAT_DEFINED */
  135. #ifdef __cplusplus
  136. extern "C" {
  137. #endif
  138. int _fstat (int, struct _stat*);
  139. int _chmod (const char*, int);
  140. int _stat (const char*, struct _stat*);
  141. #if defined (__MSVCRT__)
  142. int _fstati64(int, struct _stati64 *);
  143. int _stati64(const char *, struct _stati64 *);
  144. #if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
  145. int _wstat(const wchar_t*, struct _stat*);
  146. int _wstati64 (const wchar_t*, struct _stati64*);
  147. #define _WSTAT_DEFINED
  148. #endif /* _WSTAT_DEFIND */
  149. #endif /* __MSVCRT__ */
  150. #ifndef _NO_OLDNAMES
  151. /* These functions live in liboldnames.a. */
  152. int fstat (int, struct stat*);
  153. int chmod (const char*, int);
  154. int stat (const char*, struct stat*);
  155. #endif /* Not _NO_OLDNAMES */
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* Not RC_INVOKED */
  160. #endif /* Not _STAT_H_ */
  161. #endif /* Not __STRICT_ANSI__ */