From 6ef5ee3f14a60d66bbd0390db9a5fb18995b1882 Mon Sep 17 00:00:00 2001 From: Ivan Zhakov Date: Mon, 6 Feb 2023 13:18:35 +0000 Subject: Merge r1859174 from trunk: 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). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1907465 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ file_io/win32/dir.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index f4b83a38e..3460b9e80 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Changes for APR 1.7.3 *) apr_socket_sendfile: Use WSAIoctl() to get TransmitFile function pointer on Windows. + *) apr_dir_read: Do not request short file names on Windows 7 + and later. [Ivan Zhakov] + Changes for APR 1.7.2 *) Correct a packaging issue in 1.7.1. The contents of the release were diff --git a/file_io/win32/dir.c b/file_io/win32/dir.c index 8c8b74546..e4e3f7c73 100644 --- a/file_io/win32/dir.c +++ b/file_io/win32/dir.c @@ -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(); -- cgit v1.2.1