3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/msvcrt/sys/fstat.c
6 * PURPOSE: Gather file information
18 int _fstati64(int fd
, struct _stati64
* statbuf
)
20 BY_HANDLE_FILE_INFORMATION FileInformation
;
30 if ((void*)-1 == (handle
= (void*)_get_osfhandle(fd
)))
38 memset(statbuf
, 0, sizeof(struct _stati64
));
40 dwFileType
= GetFileType(handle
);
42 if (dwFileType
== FILE_TYPE_DISK
)
44 if (!GetFileInformationByHandle(handle
,&FileInformation
))
49 statbuf
->st_ctime
= FileTimeToUnixTime(&FileInformation
.ftCreationTime
,NULL
);
50 statbuf
->st_atime
= FileTimeToUnixTime(&FileInformation
.ftLastAccessTime
,NULL
);
51 statbuf
->st_mtime
= FileTimeToUnixTime(&FileInformation
.ftLastWriteTime
,NULL
);
54 statbuf
->st_size
= (((__int64
)FileInformation
.nFileSizeHigh
) << 32) +
55 FileInformation
.nFileSizeLow
;
56 statbuf
->st_mode
= S_IREAD
;
57 if (FileInformation
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
58 statbuf
->st_mode
|= S_IFDIR
;
60 statbuf
->st_mode
|= S_IFREG
;
61 if (!(FileInformation
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
)) statbuf
->st_mode
|= S_IWRITE
;
63 else if (dwFileType
== FILE_TYPE_CHAR
)
66 statbuf
->st_mode
= S_IFCHR
;
68 else if (dwFileType
== FILE_TYPE_PIPE
)
71 statbuf
->st_mode
= S_IFIFO
;
75 // dwFileType is FILE_TYPE_UNKNOWN or has a bad value