2 #include <msvcrt/sys/types.h>
3 #include <msvcrt/sys/stat.h>
4 #include <msvcrt/fcntl.h>
6 #include <msvcrt/errno.h>
7 #include <msvcrt/string.h>
8 #include <msvcrt/internal/file.h>
11 int _wstat (const wchar_t *path
, struct stat
*buffer
)
14 WIN32_FIND_DATAW findData
;
22 if(wcschr(path
, L
'*') || wcschr(path
, L
'?'))
28 findHandle
= FindFirstFileW(path
, &findData
);
29 if (findHandle
== INVALID_HANDLE_VALUE
)
35 FindClose(findHandle
);
37 memset (buffer
, 0, sizeof(struct stat
));
39 buffer
->st_ctime
= FileTimeToUnixTime(&findData
.ftCreationTime
,NULL
);
40 buffer
->st_atime
= FileTimeToUnixTime(&findData
.ftLastAccessTime
,NULL
);
41 buffer
->st_mtime
= FileTimeToUnixTime(&findData
.ftLastWriteTime
,NULL
);
43 // statbuf->st_dev = fd;
44 buffer
->st_size
= findData
.nFileSizeLow
;
45 buffer
->st_mode
= S_IREAD
;
46 if (findData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
47 buffer
->st_mode
|= S_IFDIR
;
49 buffer
->st_mode
|= S_IFREG
;
50 if (!(findData
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
))
51 buffer
->st_mode
|= S_IWRITE
;
56 __int64
_stati64 (const char *path
, struct _stati64
*buffer
)
59 WIN32_FIND_DATAA findData
;
67 if(strchr(path
, '*') || strchr(path
, '?'))
73 findHandle
= FindFirstFileA(path
, &findData
);
74 if (findHandle
== INVALID_HANDLE_VALUE
)
80 FindClose(findHandle
);
82 memset (buffer
, 0, sizeof(struct stat
));
84 buffer
->st_ctime
= FileTimeToUnixTime(&findData
.ftCreationTime
,NULL
);
85 buffer
->st_atime
= FileTimeToUnixTime(&findData
.ftLastAccessTime
,NULL
);
86 buffer
->st_mtime
= FileTimeToUnixTime(&findData
.ftLastWriteTime
,NULL
);
88 // statbuf->st_dev = fd;
89 buffer
->st_size
= (((__int64
)findData
.nFileSizeHigh
) << 32) +
90 findData
.nFileSizeLow
;
91 buffer
->st_mode
= S_IREAD
;
92 if (findData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
93 buffer
->st_mode
|= S_IFDIR
;
95 buffer
->st_mode
|= S_IFREG
;
96 if (!(findData
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
))
97 buffer
->st_mode
|= S_IWRITE
;
102 __int64
_wstati64 (const wchar_t *path
, struct _stati64
*buffer
)
105 WIN32_FIND_DATAW findData
;
113 if(wcschr(path
, L
'*') || wcschr(path
, L
'?'))
119 findHandle
= FindFirstFileW(path
, &findData
);
120 if (findHandle
== INVALID_HANDLE_VALUE
)
126 FindClose(findHandle
);
128 memset (buffer
, 0, sizeof(struct stat
));
130 buffer
->st_ctime
= FileTimeToUnixTime(&findData
.ftCreationTime
,NULL
);
131 buffer
->st_atime
= FileTimeToUnixTime(&findData
.ftLastAccessTime
,NULL
);
132 buffer
->st_mtime
= FileTimeToUnixTime(&findData
.ftLastWriteTime
,NULL
);
134 // statbuf->st_dev = fd;
135 buffer
->st_size
= (((__int64
)findData
.nFileSizeHigh
) << 32) +
136 findData
.nFileSizeLow
;
137 buffer
->st_mode
= S_IREAD
;
138 if (findData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
139 buffer
->st_mode
|= S_IFDIR
;
141 buffer
->st_mode
|= S_IFREG
;
142 if (!(findData
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
))
143 buffer
->st_mode
|= S_IWRITE
;