2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
8 * 25/11/05: Added license header
17 int _stat(const char* path
, struct _stat
* buffer
)
19 WIN32_FILE_ATTRIBUTE_DATA fileAttributeData
;
28 if (strchr(path
, '*') || strchr(path
, '?'))
34 if (!GetFileAttributesExA(path
, GetFileExInfoStandard
, &fileAttributeData
))
40 memset (buffer
, 0, sizeof(struct stat
));
42 buffer
->st_ctime
= FileTimeToUnixTime(&fileAttributeData
.ftCreationTime
,NULL
);
43 buffer
->st_atime
= FileTimeToUnixTime(&fileAttributeData
.ftLastAccessTime
,NULL
);
44 buffer
->st_mtime
= FileTimeToUnixTime(&fileAttributeData
.ftLastWriteTime
,NULL
);
46 // statbuf->st_dev = fd;
47 buffer
->st_size
= fileAttributeData
.nFileSizeLow
;
48 buffer
->st_mode
= S_IREAD
;
49 if (fileAttributeData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
50 buffer
->st_mode
|= S_IFDIR
;
53 buffer
->st_mode
|= S_IFREG
;
54 ext
= strrchr(path
, '.');
55 if (ext
&& (!_stricmp(ext
, ".exe") ||
56 !_stricmp(ext
, ".com") ||
57 !_stricmp(ext
, ".bat") ||
58 !_stricmp(ext
, ".cmd")))
59 buffer
->st_mode
|= S_IEXEC
;
61 if (!(fileAttributeData
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
))
62 buffer
->st_mode
|= S_IWRITE
;
70 int _stati64 (const char *path
, struct _stati64
*buffer
)
72 WIN32_FILE_ATTRIBUTE_DATA fileAttributeData
;
81 if(strchr(path
, '*') || strchr(path
, '?'))
87 if (!GetFileAttributesExA(path
, GetFileExInfoStandard
, &fileAttributeData
))
93 memset (buffer
, 0, sizeof(struct _stati64
));
95 buffer
->st_ctime
= FileTimeToUnixTime(&fileAttributeData
.ftCreationTime
,NULL
);
96 buffer
->st_atime
= FileTimeToUnixTime(&fileAttributeData
.ftLastAccessTime
,NULL
);
97 buffer
->st_mtime
= FileTimeToUnixTime(&fileAttributeData
.ftLastWriteTime
,NULL
);
99 // statbuf->st_dev = fd;
100 buffer
->st_size
= ((((__int64
)fileAttributeData
.nFileSizeHigh
) << 16) << 16) +
101 fileAttributeData
.nFileSizeLow
;
102 buffer
->st_mode
= S_IREAD
;
103 if (fileAttributeData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
104 buffer
->st_mode
|= S_IFDIR
;
107 buffer
->st_mode
|= S_IFREG
;
108 ext
= strrchr(path
, '.');
109 if (ext
&& (!_stricmp(ext
, ".exe") ||
110 !_stricmp(ext
, ".com") ||
111 !_stricmp(ext
, ".bat") ||
112 !_stricmp(ext
, ".cmd")))
113 buffer
->st_mode
|= S_IEXEC
;
115 if (!(fileAttributeData
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
))
116 buffer
->st_mode
|= S_IWRITE
;