- buf = MALLOC(bufsize);
- if (!buf)
- return WIMLIB_ERR_NOMEM;
- for (;;) {
- status = (*func_NtQueryDirectoryFile)(hDir, NULL, NULL, NULL,
- &io_status, buf, bufsize,
- FileNamesInformation,
- FALSE, NULL, restartScan);
- restartScan = FALSE;
- if (status != STATUS_SUCCESS) {
- if (status == STATUS_NO_MORE_FILES ||
- status == STATUS_NO_MORE_ENTRIES ||
- status == STATUS_NO_MORE_MATCHES) {
- ret = 0;
- } else {
- set_errno_from_nt_status(status);
- ERROR_WITH_ERRNO("Failed to read directory "
- "\"%ls\"", dir_path);
- ret = WIMLIB_ERR_READ;
- }
- goto out_free_buf;
+ NTSTATUS status;
+ IO_STATUS_BLOCK io_status;
+ const size_t bufsize = 8192;
+ u8 *buf;
+ BOOL restartScan = TRUE;
+ const FILE_NAMES_INFORMATION *info;
+
+ buf = MALLOC(bufsize);
+ if (!buf)
+ return WIMLIB_ERR_NOMEM;
+ for (;;) {
+ status = (*func_NtQueryDirectoryFile)(hDir, NULL, NULL, NULL,
+ &io_status, buf, bufsize,
+ FileNamesInformation,
+ FALSE, NULL, restartScan);
+ restartScan = FALSE;
+ if (status != STATUS_SUCCESS) {
+ if (status == STATUS_NO_MORE_FILES ||
+ status == STATUS_NO_MORE_ENTRIES ||
+ status == STATUS_NO_MORE_MATCHES) {
+ ret = 0;
+ } else if (status == STATUS_NOT_IMPLEMENTED ||
+ status == STATUS_NOT_SUPPORTED ||
+ status == STATUS_INVALID_INFO_CLASS) {
+ FREE(buf);
+ goto use_FindFirstFile;
+ } else {
+ set_errno_from_nt_status(status);
+ ERROR_WITH_ERRNO("Failed to read directory "
+ "\"%ls\"", dir_path);
+ ret = WIMLIB_ERR_READ;