summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2016-12-19 18:29:34 +0000
committerIvan Zhakov <ivan@apache.org>2016-12-19 18:29:34 +0000
commit049be06d16c4a2e575f6bfafa8c7db69f671433f (patch)
treef078de86f9269c7f8687f4b8f9494a32a2674b32 /file_io
parentbf41531dfa5258954f11922edbdbc8bd371b8f97 (diff)
downloadapr-049be06d16c4a2e575f6bfafa8c7db69f671433f.tar.gz
Merge r1774712 from trunk:
* Optimize apr_file_info_get(APR_FINFO_SIZE) on Windows. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1775154 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/win32/filestat.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c
index 0d2225a96..2a58aabfb 100644
--- a/file_io/win32/filestat.c
+++ b/file_io/win32/filestat.c
@@ -427,6 +427,24 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t want
return rv;
}
+ /* GetFileInformationByHandle() is implemented via two syscalls:
+ * QueryInformationVolume and QueryAllInformationFile. Use cheaper
+ * GetFileSizeEx() API if we only need to get the file size. */
+ if (wanted == APR_FINFO_SIZE) {
+ LARGE_INTEGER size;
+
+ if (!GetFileSizeEx(thefile->filehand, &size)) {
+ return apr_get_os_error();
+ }
+
+ finfo->pool = thefile->pool;
+ finfo->fname = thefile->fname;
+ finfo->size = size.QuadPart;
+ finfo->valid = APR_FINFO_SIZE;
+
+ return APR_SUCCESS;
+ }
+
if (!GetFileInformationByHandle(thefile->filehand, &FileInfo)) {
return apr_get_os_error();
}