Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /**
  2.  * This file has no copyright assigned and is placed in the Public Domain.
  3.  * This file is part of the w64 mingw-runtime package.
  4.  * No warranty is given; refer to the file DISCLAIMER within this package.
  5.  */
  6. #ifndef _INC_STAT
  7. #define _INC_STAT
  8.  
  9. #ifndef _WIN32
  10. #error Only Win32 target is supported!
  11. #endif
  12.  
  13. #include <_mingw.h>
  14. #include <io.h>
  15.  
  16. #pragma pack(push,_CRT_PACKING)
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22. #ifndef _CRTIMP
  23. #define _CRTIMP __declspec(dllimport)
  24. #endif
  25.  
  26. #include <sys/types.h>
  27.  
  28. #ifndef __TINYC__ /* gr */
  29. #ifdef _USE_32BIT_TIME_T
  30. #ifdef _WIN64
  31. #undef _USE_32BIT_TIME_T
  32. #endif
  33. #else
  34. #if _INTEGRAL_MAX_BITS < 64
  35. #define _USE_32BIT_TIME_T
  36. #endif
  37. #endif
  38. #endif
  39.  
  40. #ifndef _TIME32_T_DEFINED
  41.   typedef long __time32_t;
  42. #define _TIME32_T_DEFINED
  43. #endif
  44.  
  45. #ifndef _TIME64_T_DEFINED
  46. #if _INTEGRAL_MAX_BITS >= 64
  47.   typedef __int64 __time64_t;
  48. #endif
  49. #define _TIME64_T_DEFINED
  50. #endif
  51.  
  52. #ifndef _TIME_T_DEFINED
  53. #ifdef _USE_32BIT_TIME_T
  54.   typedef __time32_t time_t;
  55. #else
  56.   typedef __time64_t time_t;
  57. #endif
  58. #define _TIME_T_DEFINED
  59. #endif
  60.  
  61. #ifndef _WCHAR_T_DEFINED
  62.   typedef unsigned short wchar_t;
  63. #define _WCHAR_T_DEFINED
  64. #endif
  65.  
  66. #ifndef _STAT_DEFINED
  67.  
  68. #ifdef _USE_32BIT_TIME_T
  69. #ifndef _WIN64
  70. #define _fstat32 _fstat
  71. #define _stat32 _stat
  72. #define _wstat32 _wstat
  73. #else
  74. #define _fstat _fstat32
  75. #define _stat _stat32
  76. #define _wstat _wstat32
  77. #endif
  78. #define _fstati64 _fstat32i64
  79. #define _stati64 _stat32i64
  80. #define _wstati64 _wstat32i64
  81. #else
  82. #define _fstat _fstat64i32
  83. #define _fstati64 _fstat64
  84. #define _stat _stat64i32
  85. #define _stati64 _stat64
  86. #define _wstat _wstat64i32
  87. #define _wstati64 _wstat64
  88. #endif
  89.  
  90.   struct _stat32 {
  91.     _dev_t st_dev;
  92.     _ino_t st_ino;
  93.     unsigned short st_mode;
  94.     short st_nlink;
  95.     short st_uid;
  96.     short st_gid;
  97.     _dev_t st_rdev;
  98.     _off_t st_size;
  99.     __time32_t st_atime;
  100.     __time32_t st_mtime;
  101.     __time32_t st_ctime;
  102.   };
  103.  
  104. #ifndef NO_OLDNAMES
  105.   struct stat {
  106.     _dev_t st_dev;
  107.     _ino_t st_ino;
  108.     unsigned short st_mode;
  109.     short st_nlink;
  110.     short st_uid;
  111.     short st_gid;
  112.     _dev_t st_rdev;
  113.     _off_t st_size;
  114.     time_t st_atime;
  115.     time_t st_mtime;
  116.     time_t st_ctime;
  117.   };
  118. #endif
  119.  
  120. #if _INTEGRAL_MAX_BITS >= 64
  121.   struct _stat32i64 {
  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.     __time32_t st_atime;
  131.     __time32_t st_mtime;
  132.     __time32_t st_ctime;
  133.   };
  134.  
  135.   struct _stat64i32 {
  136.     _dev_t st_dev;
  137.     _ino_t st_ino;
  138.     unsigned short st_mode;
  139.     short st_nlink;
  140.     short st_uid;
  141.     short st_gid;
  142.     _dev_t st_rdev;
  143.     _off_t st_size;
  144.     __time64_t st_atime;
  145.     __time64_t st_mtime;
  146.     __time64_t st_ctime;
  147.   };
  148.  
  149.   struct _stat64 {
  150.     _dev_t st_dev;
  151.     _ino_t st_ino;
  152.     unsigned short st_mode;
  153.     short st_nlink;
  154.     short st_uid;
  155.     short st_gid;
  156.     _dev_t st_rdev;
  157.     __int64 st_size;
  158.     __time64_t st_atime;
  159.     __time64_t st_mtime;
  160.     __time64_t st_ctime;
  161.   };
  162. #endif
  163.  
  164. #define __stat64 _stat64
  165.  
  166. #define _STAT_DEFINED
  167. #endif
  168.  
  169. #define _S_IFMT 0xF000
  170. #define _S_IFDIR 0x4000
  171. #define _S_IFCHR 0x2000
  172. #define _S_IFIFO 0x1000
  173. #define _S_IFREG 0x8000
  174. #define _S_IREAD 0x0100
  175. #define _S_IWRITE 0x0080
  176. #define _S_IEXEC 0x0040
  177.  
  178.   _CRTIMP int __cdecl _fstat32(int _FileDes,struct _stat32 *_Stat);
  179.   _CRTIMP int __cdecl _stat32(const char *_Name,struct _stat32 *_Stat);
  180. #if _INTEGRAL_MAX_BITS >= 64
  181.   _CRTIMP int __cdecl _fstat64(int _FileDes,struct _stat64 *_Stat);
  182.   _CRTIMP int __cdecl _fstat32i64(int _FileDes,struct _stat32i64 *_Stat);
  183.   int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat);
  184.   __CRT_INLINE int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat)
  185.   {
  186.     struct _stat64 st;
  187.     int ret=_fstat64(_FileDes,&st);
  188.     _Stat->st_dev=st.st_dev;
  189.     _Stat->st_ino=st.st_ino;
  190.     _Stat->st_mode=st.st_mode;
  191.     _Stat->st_nlink=st.st_nlink;
  192.     _Stat->st_uid=st.st_uid;
  193.     _Stat->st_gid=st.st_gid;
  194.     _Stat->st_rdev=st.st_rdev;
  195.     _Stat->st_size=(_off_t) st.st_size;
  196.     _Stat->st_atime=st.st_atime;
  197.     _Stat->st_mtime=st.st_mtime;
  198.     _Stat->st_ctime=st.st_ctime;
  199.     return ret;
  200.   }
  201.   _CRTIMP int __cdecl _stat64(const char *_Name,struct _stat64 *_Stat);
  202.   _CRTIMP int __cdecl _stat32i64(const char *_Name,struct _stat32i64 *_Stat);
  203.   int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
  204.   __CRT_INLINE int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
  205.   {
  206.     struct _stat64 st;
  207.     int ret=_stat64(_Name,&st);
  208.     _Stat->st_dev=st.st_dev;
  209.     _Stat->st_ino=st.st_ino;
  210.     _Stat->st_mode=st.st_mode;
  211.     _Stat->st_nlink=st.st_nlink;
  212.     _Stat->st_uid=st.st_uid;
  213.     _Stat->st_gid=st.st_gid;
  214.     _Stat->st_rdev=st.st_rdev;
  215.     _Stat->st_size=(_off_t) st.st_size;
  216.     _Stat->st_atime=st.st_atime;
  217.     _Stat->st_mtime=st.st_mtime;
  218.     _Stat->st_ctime=st.st_ctime;
  219.     return ret;
  220.   }
  221. #endif
  222.  
  223. #ifndef _WSTAT_DEFINED
  224. #define _WSTAT_DEFINED
  225.   _CRTIMP int __cdecl _wstat32(const wchar_t *_Name,struct _stat32 *_Stat);
  226. #if _INTEGRAL_MAX_BITS >= 64
  227.   _CRTIMP int __cdecl _wstat32i64(const wchar_t *_Name,struct _stat32i64 *_Stat);
  228.   int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat);
  229.   _CRTIMP int __cdecl _wstat64(const wchar_t *_Name,struct _stat64 *_Stat);
  230. #endif
  231. #endif
  232.  
  233. #ifndef NO_OLDNAMES
  234. #define _S_IFBLK        0x3000  /* Block: Is this ever set under w32? */
  235.  
  236. #define S_IFMT _S_IFMT
  237. #define S_IFDIR _S_IFDIR
  238. #define S_IFCHR _S_IFCHR
  239. #define S_IFREG _S_IFREG
  240. #define S_IREAD _S_IREAD
  241. #define S_IWRITE _S_IWRITE
  242. #define S_IEXEC _S_IEXEC
  243. #define S_IFIFO         _S_IFIFO
  244. #define S_IFBLK         _S_IFBLK
  245.  
  246. #define _S_IRWXU        (_S_IREAD | _S_IWRITE | _S_IEXEC)
  247. #define _S_IXUSR        _S_IEXEC
  248. #define _S_IWUSR        _S_IWRITE
  249.  
  250. #define S_IRWXU         _S_IRWXU
  251. #define S_IXUSR         _S_IXUSR
  252. #define S_IWUSR         _S_IWUSR
  253. #define S_IRUSR         _S_IRUSR
  254. #define _S_IRUSR        _S_IREAD
  255.  
  256. #define S_ISDIR(m)      (((m) & S_IFMT) == S_IFDIR)
  257. #define S_ISFIFO(m)     (((m) & S_IFMT) == S_IFIFO)
  258. #define S_ISCHR(m)      (((m) & S_IFMT) == S_IFCHR)
  259. #define S_ISBLK(m)      (((m) & S_IFMT) == S_IFBLK)
  260. #define S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)
  261.  
  262. #endif
  263.  
  264. #if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
  265. int __cdecl stat(const char *_Filename,struct stat *_Stat);
  266. int __cdecl fstat(int _Desc,struct stat *_Stat);
  267. int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat);
  268. #ifdef _USE_32BIT_TIME_T
  269. __CRT_INLINE int __cdecl fstat(int _Desc,struct stat *_Stat) {
  270.   return _fstat32(_Desc,(struct _stat32 *)_Stat);
  271. }
  272. __CRT_INLINE int __cdecl stat(const char *_Filename,struct stat *_Stat) {
  273.   return _stat32(_Filename,(struct _stat32 *)_Stat);
  274. }
  275. #else
  276. __CRT_INLINE int __cdecl fstat(int _Desc,struct stat *_Stat) {
  277.   return _fstat64i32(_Desc,(struct _stat64i32 *)_Stat);
  278. }
  279. __CRT_INLINE int __cdecl stat(const char *_Filename,struct stat *_Stat) {
  280.   return _stat64i32(_Filename,(struct _stat64i32 *)_Stat);
  281. }
  282. #endif
  283. #endif
  284.  
  285. #ifdef __cplusplus
  286. }
  287. #endif
  288.  
  289. #pragma pack(pop)
  290. #endif
  291.