aboutsummaryrefslogtreecommitdiff
path: root/src/win/winapi.c
diff options
context:
space:
mode:
authorHüseyin Açacak <110401522+huseyinacacak-janea@users.noreply.github.com>2024-07-30 15:58:41 +0300
committerGitHub <noreply@github.com>2024-07-30 08:58:41 -0400
commit4e310d0f90af29e699e2dedad5fa0dcee181a7cc (patch)
treec58cdf3ede7eebe4c7b43710f0e88dd11464b5ed /src/win/winapi.c
parentf23037fe21ef8e7d36ebeaf5c8a589bd8e56d3dd (diff)
downloadlibuv-4e310d0f90af29e699e2dedad5fa0dcee181a7cc.tar.gz
libuv-4e310d0f90af29e699e2dedad5fa0dcee181a7cc.zip
win,fs: use the new Windows fast stat API (#4327)
Windows added a new API for file information, which doesn't have to open the file thus greatly improving performance: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfileinformationbyname The stat functions are already covered by tests, so no test was added here. I considered comparing the result of old and new code, but that would require exposing internal fs functions, and we would be testing Windows functionality, not libuv.
Diffstat (limited to 'src/win/winapi.c')
-rw-r--r--src/win/winapi.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/win/winapi.c b/src/win/winapi.c
index 53147b82..4add0e27 100644
--- a/src/win/winapi.c
+++ b/src/win/winapi.c
@@ -48,12 +48,16 @@ sSetWinEventHook pSetWinEventHook;
/* ws2_32.dll function pointer */
uv_sGetHostNameW pGetHostNameW;
+/* api-ms-win-core-file-l2-1-4.dll function pointer */
+sGetFileInformationByName pGetFileInformationByName;
+
void uv__winapi_init(void) {
HMODULE ntdll_module;
HMODULE powrprof_module;
HMODULE user32_module;
HMODULE kernel32_module;
HMODULE ws2_32_module;
+ HMODULE api_win_core_file_module;
ntdll_module = GetModuleHandleA("ntdll.dll");
if (ntdll_module == NULL) {
@@ -144,4 +148,10 @@ void uv__winapi_init(void) {
ws2_32_module,
"GetHostNameW");
}
+
+ api_win_core_file_module = GetModuleHandleA("api-ms-win-core-file-l2-1-4.dll");
+ if (api_win_core_file_module != NULL) {
+ pGetFileInformationByName = (sGetFileInformationByName)GetProcAddress(
+ api_win_core_file_module, "GetFileInformationByName");
+ }
}