xref: /reactos/sdk/lib/crt/stdio/stat.c (revision 84ccccab)
1 #include <precomp.h>
2 #include <tchar.h>
3 
4 #define stat64_to_stat(buf64, buf)   \
5     do { \
6     buf->st_dev   = (buf64)->st_dev;   \
7     buf->st_ino   = (buf64)->st_ino;   \
8     buf->st_mode  = (buf64)->st_mode;  \
9     buf->st_nlink = (buf64)->st_nlink; \
10     buf->st_uid   = (buf64)->st_uid;   \
11     buf->st_gid   = (buf64)->st_gid;   \
12     buf->st_rdev  = (buf64)->st_rdev;  \
13     buf->st_size  = (_off_t)(buf64)->st_size;  \
14     buf->st_atime = (time_t)(buf64)->st_atime; \
15     buf->st_mtime = (time_t)(buf64)->st_mtime; \
16     buf->st_ctime = (time_t)(buf64)->st_ctime; \
17     } while (0)
18 
19 int CDECL _tstat(const _TCHAR* path, struct _stat * buf)
20 {
21   int ret;
22   struct __stat64 buf64;
23 
24   ret = _tstat64(path, &buf64);
25   if (!ret)
26     stat64_to_stat(&buf64, buf);
27   return ret;
28 }
29 
30 int CDECL _tstati64(const _TCHAR* path, struct _stati64 * buf)
31 {
32   int ret;
33   struct __stat64 buf64;
34 
35   ret = _tstat64(path, &buf64);
36   if (!ret)
37     stat64_to_stat(&buf64, buf);
38   return ret;
39 }
40 
41 #ifndef _UNICODE
42 
43 int CDECL _fstat(int fd, struct _stat* buf)
44 { int ret;
45   struct __stat64 buf64;
46 
47   ret = _fstat64(fd, &buf64);
48   if (!ret)
49       stat64_to_stat(&buf64, buf);
50   return ret;
51 }
52 
53 int CDECL _fstati64(int fd, struct _stati64* buf)
54 {
55   int ret;
56   struct __stat64 buf64;
57 
58   ret = _fstat64(fd, &buf64);
59   if (!ret)
60     stat64_to_stat(&buf64, buf);
61   return ret;
62 }
63 
64 #endif
65