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
)
20 if ( ! (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
))
22 int fd
= _open(path
,_O_RDONLY
);
25 ret
= fstat(fd
,buffer
);
30 buffer
->st_ctime
= FileTimeToUnixTime( &wfd
.ftCreationTime
,NULL
);
31 buffer
->st_atime
= FileTimeToUnixTime( &wfd
.ftLastAccessTime
,NULL
);
32 buffer
->st_mtime
= FileTimeToUnixTime( &wfd
.ftLastWriteTime
,NULL
);
34 if (buffer
->st_atime
==0)
35 buffer
->st_atime
= buffer
->st_mtime
;
36 if (buffer
->st_ctime
==0)
37 buffer
->st_ctime
= buffer
->st_mtime
;
39 buffer
->st_mode
= S_IREAD
;
40 if (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
41 buffer
->st_mode
|= S_IFDIR
;
43 buffer
->st_mode
|= S_IFREG
;
44 if ( ! (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
))
45 buffer
->st_mode
|= S_IWRITE
| S_IEXEC
;
47 buffer
->st_size
= wfd
.nFileSizeLow
;
49 if (FindNextFile(fh
,&wfd
))