summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2023-02-06 13:18:35 +0000
committerIvan Zhakov <ivan@apache.org>2023-02-06 13:18:35 +0000
commit6ef5ee3f14a60d66bbd0390db9a5fb18995b1882 (patch)
tree431e3b0d394a595d9db83d141a06e00591fd5123
parent74d2332b35a3242f775bfadef02e22b39aed98cd (diff)
downloadapr-6ef5ee3f14a60d66bbd0390db9a5fb18995b1882.tar.gz
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
-rw-r--r--CHANGES3
-rw-r--r--file_io/win32/dir.c16
2 files changed, 18 insertions, 1 deletions
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();