home *** CD-ROM | disk | FTP | other *** search
/ Beginning C++ Through Gam…rogramming (2nd Edition) / BCGP2E.ISO / bloodshed / devcpp-4.9.9.2_setup.exe / stat.h < prev    next >
C/C++ Source or Header  |  2005-01-29  |  5KB  |  195 lines

  1. /*
  2.  * stat.h
  3.  * This file has no copyright assigned and is placed in the Public Domain.
  4.  * This file is a part of the mingw-runtime package.
  5.  * No warranty is given; refer to the file DISCLAIMER within the package.
  6.  *
  7.  * Symbolic constants for opening and creating files, also stat, fstat and
  8.  * chmod functions.
  9.  *
  10.  */
  11.  
  12. #ifndef _STAT_H_
  13. #define _STAT_H_
  14.  
  15. /* All the headers include this file. */
  16. #include <_mingw.h>
  17.  
  18. #define __need_size_t
  19. #define __need_wchar_t
  20. #ifndef RC_INVOKED
  21. #include <stddef.h>
  22. #endif /* Not RC_INVOKED */
  23.  
  24. #include <sys/types.h>
  25.  
  26. /*
  27.  * Constants for the stat st_mode member.
  28.  */
  29. #ifndef __STRICT_ANSI__
  30. #endif
  31. #define    _S_IFIFO    0x1000    /* FIFO */
  32. #define    _S_IFCHR    0x2000    /* Character */
  33. #define    _S_IFBLK    0x3000    /* Block: Is this ever set under w32? */
  34. #define    _S_IFDIR    0x4000    /* Directory */
  35. #define    _S_IFREG    0x8000    /* Regular */
  36.  
  37. #define    _S_IFMT        0xF000    /* File type mask */
  38.  
  39. #define    _S_IEXEC    0x0040
  40. #define    _S_IWRITE    0x0080
  41. #define    _S_IREAD    0x0100
  42.  
  43. #define    _S_IRWXU    (_S_IREAD | _S_IWRITE | _S_IEXEC)
  44. #define    _S_IXUSR    _S_IEXEC
  45. #define    _S_IWUSR    _S_IWRITE
  46. #define    _S_IRUSR    _S_IREAD
  47.  
  48. #define    _S_ISDIR(m)    (((m) & _S_IFMT) == _S_IFDIR)
  49. #define    _S_ISFIFO(m)    (((m) & _S_IFMT) == _S_IFIFO)
  50. #define    _S_ISCHR(m)    (((m) & _S_IFMT) == _S_IFCHR)
  51. #define    _S_ISBLK(m)    (((m) & _S_IFMT) == _S_IFBLK)
  52. #define    _S_ISREG(m)    (((m) & _S_IFMT) == _S_IFREG)
  53.  
  54. #ifndef _NO_OLDNAMES
  55.  
  56. #define    S_IFIFO        _S_IFIFO
  57. #define    S_IFCHR        _S_IFCHR
  58. #define    S_IFBLK        _S_IFBLK
  59. #define    S_IFDIR        _S_IFDIR
  60. #define    S_IFREG        _S_IFREG
  61. #define    S_IFMT        _S_IFMT
  62. #define    S_IEXEC        _S_IEXEC
  63. #define    S_IWRITE    _S_IWRITE
  64. #define    S_IREAD        _S_IREAD
  65. #define    S_IRWXU        _S_IRWXU
  66. #define    S_IXUSR        _S_IXUSR
  67. #define    S_IWUSR        _S_IWUSR
  68. #define    S_IRUSR        _S_IRUSR
  69.  
  70. #define    S_ISDIR(m)    (((m) & S_IFMT) == S_IFDIR)
  71. #define    S_ISFIFO(m)    (((m) & S_IFMT) == S_IFIFO)
  72. #define    S_ISCHR(m)    (((m) & S_IFMT) == S_IFCHR)
  73. #define    S_ISBLK(m)    (((m) & S_IFMT) == S_IFBLK)
  74. #define    S_ISREG(m)    (((m) & S_IFMT) == S_IFREG)
  75.  
  76. #endif    /* Not _NO_OLDNAMES */
  77.  
  78. #ifndef RC_INVOKED
  79.  
  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.  
  104. struct stat
  105. {
  106.     _dev_t    st_dev;        /* Equivalent to drive number 0=A 1=B ... */
  107.     _ino_t    st_ino;        /* Always zero ? */
  108.     _mode_t    st_mode;    /* See above constants */
  109.     short    st_nlink;    /* Number of links. */
  110.     short    st_uid;        /* User: Maybe significant on NT ? */
  111.     short    st_gid;        /* Group: Ditto */
  112.     _dev_t    st_rdev;    /* Seems useless (not even filled in) */
  113.     _off_t    st_size;    /* File size in bytes */
  114.     time_t    st_atime;    /* Accessed date (always 00:00 hrs local
  115.                  * on FAT) */
  116.     time_t    st_mtime;    /* Modified time */
  117.     time_t    st_ctime;    /* Creation time */
  118. };
  119.  
  120. #if defined (__MSVCRT__)
  121. struct _stati64 {
  122.     _dev_t st_dev;
  123.     _ino_t st_ino;
  124.     unsigned short st_mode;
  125.     short st_nlink;
  126.     short st_uid;
  127.     short st_gid;
  128.     _dev_t st_rdev;
  129.     __int64 st_size;
  130.     time_t st_atime;
  131.     time_t st_mtime;
  132.     time_t st_ctime;
  133. };
  134.  
  135. struct __stat64
  136. {
  137.     _dev_t st_dev;
  138.     _ino_t st_ino;
  139.     _mode_t st_mode;
  140.     short st_nlink;
  141.     short st_uid;
  142.     short st_gid;
  143.     _dev_t st_rdev;
  144.     _off_t st_size;
  145.     __time64_t st_atime;
  146.     __time64_t st_mtime;
  147.     __time64_t st_ctime;
  148. };
  149. #endif /* __MSVCRT__ */
  150. #define _STAT_DEFINED
  151. #endif /* _STAT_DEFINED */
  152.  
  153. #ifdef    __cplusplus
  154. extern "C" {
  155. #endif
  156.  
  157. _CRTIMP int __cdecl    _fstat (int, struct _stat*);
  158. _CRTIMP int __cdecl    _chmod (const char*, int);
  159. _CRTIMP int __cdecl    _stat (const char*, struct _stat*);
  160.  
  161. #ifndef    _NO_OLDNAMES
  162.  
  163. /* These functions live in liboldnames.a. */
  164. _CRTIMP int __cdecl    fstat (int, struct stat*);
  165. _CRTIMP int __cdecl    chmod (const char*, int);
  166. _CRTIMP int __cdecl    stat (const char*, struct stat*);
  167.  
  168. #endif    /* Not _NO_OLDNAMES */
  169.  
  170. #if defined (__MSVCRT__)
  171. _CRTIMP int __cdecl  _fstati64(int, struct _stati64 *);
  172. _CRTIMP int __cdecl  _stati64(const char *, struct _stati64 *);
  173. /* These require newer versions of msvcrt.dll (6.10 or higher).  */ 
  174. #if __MSVCRT_VERSION__ >= 0x0601
  175. _CRTIMP int __cdecl _fstat64 (int, struct __stat64*);
  176. _CRTIMP int __cdecl _stat64 (const char*, struct __stat64*);
  177. #endif /* __MSVCRT_VERSION__ >= 0x0601 */
  178. #if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
  179. _CRTIMP int __cdecl    _wstat(const wchar_t*, struct _stat*);
  180. _CRTIMP int __cdecl    _wstati64 (const wchar_t*, struct _stati64*);
  181. #if __MSVCRT_VERSION__ >= 0x0601
  182. _CRTIMP int __cdecl _wstat64 (const wchar_t*, struct __stat64*);
  183. #endif /* __MSVCRT_VERSION__ >= 0x0601 */
  184. #define _WSTAT_DEFINED
  185. #endif /* _WSTAT_DEFIND */
  186. #endif /* __MSVCRT__ */
  187.  
  188. #ifdef    __cplusplus
  189. }
  190. #endif
  191.  
  192. #endif    /* Not RC_INVOKED */
  193.  
  194. #endif    /* Not _STAT_H_ */
  195.