apr_dir_read: Do not request short file names on Windows 7 and later. This
significantly improves directory listing performance on volumes with 8.3
filenames enabled (default for system volume).
@@ -128,6 +128,8 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
if (thedir->dirhand == INVALID_HANDLE_VALUE)
{
apr_status_t rv;
+ FINDEX_INFO_LEVELS info_level;
+
if ((rv = utf8_to_unicode_path(wdirname, sizeof(wdirname)
/ sizeof(apr_wchar_t),
thedir->dirname))) {
@@ -136,7 +138,19 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
eos = wcschr(wdirname, '\0');
eos[0] = '*';
eos[1] = '\0';
- thedir->dirhand = FindFirstFileW(wdirname, thedir->w.entry);
+
+ /* Do not request short file names on Windows 7 and later. */
+ if (apr_os_level >= APR_WIN_7) {
+ info_level = FindExInfoBasic;
+ }
+ else {
+ info_level = FindExInfoStandard;
+ }
+
+ thedir->dirhand = FindFirstFileExW(wdirname, info_level,
+ thedir->w.entry,
+ FindExSearchNameMatch, NULL,
+ 0);
eos[0] = '\0';
if (thedir->dirhand == INVALID_HANDLE_VALUE) {
return apr_get_os_error();
