2 #include <msvcrt/sys/types.h>
3 #include <msvcrt/sys/stat.h>
4 #include <msvcrt/fcntl.h>
6 #include <msvcrt/errno.h>
12 int _stat(const char* path, struct stat* buffer)
17 fh = FindFirstFileA(path, &wfd);
18 if (fh == INVALID_HANDLE_VALUE) {
22 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
23 int fd = _open(path, _O_RDONLY);
25 ret = fstat(fd, buffer);
29 buffer->st_ctime = FileTimeToUnixTime(&wfd.ftCreationTime,NULL);
30 buffer->st_atime = FileTimeToUnixTime(&wfd.ftLastAccessTime,NULL);
31 buffer->st_mtime = FileTimeToUnixTime(&wfd.ftLastWriteTime,NULL);
33 if (buffer->st_atime ==0)
34 buffer->st_atime = buffer->st_mtime;
35 if (buffer->st_ctime ==0)
36 buffer->st_ctime = buffer->st_mtime;
38 buffer->st_mode = S_IREAD;
39 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
40 buffer->st_mode |= S_IFDIR;
42 buffer->st_mode |= S_IFREG;
43 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
44 buffer->st_mode |= S_IWRITE | S_IEXEC;
46 buffer->st_size = wfd.nFileSizeLow;
48 if (FindNextFileA(fh, &wfd)) {