2 #include <crtdll/sys/types.h>
3 #include <crtdll/sys/stat.h>
4 #include <crtdll/fcntl.h>
6 #include <crtdll/errno.h>
9 int _stat( const char *path, struct stat *buffer )
13 fh = FindFirstFile (path,&wfd);
14 if ( fh == INVALID_HANDLE_VALUE )
19 if ( ! (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
21 int fd = _open(path,_O_RDONLY);
24 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 (FindNextFile(fh,&wfd))