diff options
-rw-r--r-- | file_io/win32/filestat.c | 18 |
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(); } |