1
2 /*
3 * @implemented
4 */
_tfindfirst(const _TCHAR * _name,struct _tfinddata_t * result)5 intptr_t _tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
6 {
7 WIN32_FIND_DATA FindFileData;
8 HANDLE hFindFile;
9
10 hFindFile = FindFirstFile(_name, &FindFileData);
11 if (hFindFile == INVALID_HANDLE_VALUE) {
12 _dosmaperr(GetLastError());
13 return -1;
14 }
15
16 result->attrib = FindFileData.dwFileAttributes;
17 result->time_create = (time_t)FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
18 result->time_access = (time_t)FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
19 result->time_write = (time_t)FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
20 result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow;
21 _tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
22
23 return (intptr_t)hFindFile;
24 }
25
26 /*
27 * @implemented
28 */
_tfindnext(intptr_t handle,struct _tfinddata_t * result)29 int _tfindnext(intptr_t handle, struct _tfinddata_t* result)
30 {
31 WIN32_FIND_DATA FindFileData;
32
33 if (!FindNextFile((HANDLE)handle, &FindFileData)) {
34 _dosmaperr(GetLastError());
35 return -1;
36 }
37
38 result->attrib = FindFileData.dwFileAttributes;
39 result->time_create = (time_t)FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
40 result->time_access = (time_t)FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
41 result->time_write = (time_t)FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
42 result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow;
43 _tcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
44
45 return 0;
46 }
47