static inline void finddata2dirent(struct dirent *ent, WIN32_FIND_DATAW *fdata) { /* convert UTF-16 name to UTF-8 (d_name points to dirent_DIR.dd_name) */ xwcstoutf(ent->d_name, fdata->cFileName, MAX_PATH * 3); /* Set file type, based on WIN32_FIND_DATA */ if (fdata->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ent->d_type = DT_DIR; else ent->d_type = DT_REG; }
/* * Allocate and initialize an fsentry from a WIN32_FIND_DATA structure. */ static struct fsentry *fseentry_create_entry(struct fsentry *list, const WIN32_FIND_DATAW *fdata) { char buf[MAX_PATH * 3]; int len; struct fsentry *fse; len = xwcstoutf(buf, fdata->cFileName, ARRAY_SIZE(buf)); fse = fsentry_alloc(list, buf, len); fse->st_mode = file_attr_to_st_mode(fdata->dwFileAttributes, fdata->dwReserved0); fse->st_size = S_ISLNK(fse->st_mode) ? MAX_LONG_PATH : fdata->nFileSizeLow | (((off_t) fdata->nFileSizeHigh) << 32); filetime_to_timespec(&(fdata->ftLastAccessTime), &(fse->st_atim)); filetime_to_timespec(&(fdata->ftLastWriteTime), &(fse->st_mtim)); filetime_to_timespec(&(fdata->ftCreationTime), &(fse->st_ctim)); return fse; }