2 #include <msvcrt/sys/types.h>
3 #include <msvcrt/sys/stat.h>
4 #include <msvcrt/fcntl.h>
6 #include <msvcrt/errno.h>
9 int _stat(const char* path, struct stat* buffer)
14 fh = FindFirstFile(path, &wfd);
15 if (fh == INVALID_HANDLE_VALUE) {
19 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
20 int fd = _open(path, _O_RDONLY);
22 ret = fstat(fd, buffer);
26 buffer->st_ctime = FileTimeToUnixTime(&wfd.ftCreationTime,NULL);
27 buffer->st_atime = FileTimeToUnixTime(&wfd.ftLastAccessTime,NULL);
28 buffer->st_mtime = FileTimeToUnixTime(&wfd.ftLastWriteTime,NULL);
30 if (buffer->st_atime ==0)
31 buffer->st_atime = buffer->st_mtime;
32 if (buffer->st_ctime ==0)
33 buffer->st_ctime = buffer->st_mtime;
35 buffer->st_mode = S_IREAD;
36 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
37 buffer->st_mode |= S_IFDIR;
39 buffer->st_mode |= S_IFREG;
40 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
41 buffer->st_mode |= S_IWRITE | S_IEXEC;
43 buffer->st_size = wfd.nFileSizeLow;
45 if (FindNextFile(fh, &wfd)) {