equal
deleted
inserted
replaced
663 |
663 |
664 if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) { |
664 if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) { |
665 d = dir_calloc(); |
665 d = dir_calloc(); |
666 if (d != NULL) { |
666 if (d != NULL) { |
667 wchar_t search_path[MAX_PATH]; |
667 wchar_t search_path[MAX_PATH]; |
668 /* build search path for FindFirstFile */ |
668 bool slash = path[wcslen(path) - 1] == L'\\'; |
669 _snwprintf(search_path, lengthof(search_path), L"%s\\*", path); |
669 |
|
670 /* build search path for FindFirstFile, try not to append additional slashes |
|
671 * as it throws Win9x off its groove for root directories */ |
|
672 _snwprintf(search_path, lengthof(search_path), L"%s%s*", path, slash ? L"" : L"\\"); |
670 *lastof(search_path) = '\0'; |
673 *lastof(search_path) = '\0'; |
671 d->hFind = FindFirstFileW(search_path, &d->fd); |
674 d->hFind = FindFirstFileW(search_path, &d->fd); |
672 |
675 |
673 if (d->hFind != INVALID_HANDLE_VALUE || |
676 if (d->hFind != INVALID_HANDLE_VALUE || |
674 GetLastError() == ERROR_NO_MORE_FILES) { // the directory is empty |
677 GetLastError() == ERROR_NO_MORE_FILES) { // the directory is empty |