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
20 int _fstati64(int fd
, struct _stati64
* statbuf
)
22 BY_HANDLE_FILE_INFORMATION FileInformation
;
32 if ((void*)-1 == (handle
= (void*)_get_osfhandle(fd
)))
40 memset(statbuf
, 0, sizeof(struct _stati64
));
42 dwFileType
= GetFileType(handle
);
44 if (dwFileType
== FILE_TYPE_DISK
)
46 if (!GetFileInformationByHandle(handle
,&FileInformation
))
51 statbuf
->st_ctime
= FileTimeToUnixTime(&FileInformation
.ftCreationTime
,NULL
);
52 statbuf
->st_atime
= FileTimeToUnixTime(&FileInformation
.ftLastAccessTime
,NULL
);
53 statbuf
->st_mtime
= FileTimeToUnixTime(&FileInformation
.ftLastWriteTime
,NULL
);
56 statbuf
->st_size
= (((__int64
)FileInformation
.nFileSizeHigh
) << 32) +
57 FileInformation
.nFileSizeLow
;
58 statbuf
->st_mode
= S_IREAD
;
59 if (FileInformation
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
60 statbuf
->st_mode
|= S_IFDIR
;
62 statbuf
->st_mode
|= S_IFREG
;
63 if (!(FileInformation
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
)) statbuf
->st_mode
|= S_IWRITE
;
65 else if (dwFileType
== FILE_TYPE_CHAR
)
68 statbuf
->st_mode
= S_IFCHR
;
70 else if (dwFileType
== FILE_TYPE_PIPE
)
73 statbuf
->st_mode
= S_IFIFO
;
77 // dwFileType is FILE_TYPE_UNKNOWN or has a bad value
84 int _fstat64(int fd
, struct __stat64
* buf
)