diff options
author | Hüseyin Açacak <110401522+huseyinacacak-janea@users.noreply.github.com> | 2024-07-30 15:58:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-30 08:58:41 -0400 |
commit | 4e310d0f90af29e699e2dedad5fa0dcee181a7cc (patch) | |
tree | c58cdf3ede7eebe4c7b43710f0e88dd11464b5ed /src/win/winapi.h | |
parent | f23037fe21ef8e7d36ebeaf5c8a589bd8e56d3dd (diff) | |
download | libuv-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.h')
-rw-r--r-- | src/win/winapi.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/win/winapi.h b/src/win/winapi.h index d3449c18..6d948236 100644 --- a/src/win/winapi.h +++ b/src/win/winapi.h @@ -4125,6 +4125,24 @@ typedef const UNICODE_STRING *PCUNICODE_STRING; # define DEVICE_TYPE DWORD #endif +typedef struct _FILE_STAT_BASIC_INFORMATION { + LARGE_INTEGER FileId; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; + ULONG ReparseTag; + ULONG NumberOfLinks; + ULONG DeviceType; + ULONG DeviceCharacteristics; + ULONG Reserved; + FILE_ID_128 FileId128; + LARGE_INTEGER VolumeSerialNumber; +} FILE_STAT_BASIC_INFORMATION; + /* MinGW already has a definition for REPARSE_DATA_BUFFER, but mingw-w64 does * not. */ @@ -4752,6 +4770,21 @@ typedef struct _TCP_INITIAL_RTO_PARAMETERS { # define SIO_TCP_INITIAL_RTO _WSAIOW(IOC_VENDOR,17) #endif +/* from winnt.h */ +typedef enum _FILE_INFO_BY_NAME_CLASS { + FileStatByNameInfo, + FileStatLxByNameInfo, + FileCaseSensitiveByNameInfo, + FileStatBasicByNameInfo, + MaximumFileInfoByNameClass +} FILE_INFO_BY_NAME_CLASS; + +typedef BOOL(WINAPI* sGetFileInformationByName)( + PCWSTR FileName, + FILE_INFO_BY_NAME_CLASS FileInformationClass, + PVOID FileInfoBuffer, + ULONG FileInfoBufferSize); + /* Ntdll function pointers */ extern sRtlGetVersion pRtlGetVersion; extern sRtlNtStatusToDosError pRtlNtStatusToDosError; @@ -4772,6 +4805,9 @@ extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotifi /* User32.dll function pointer */ extern sSetWinEventHook pSetWinEventHook; +/* api-ms-win-core-file-l2-1-4.dll function pointers */ +extern sGetFileInformationByName pGetFileInformationByName; + /* ws2_32.dll function pointer */ /* mingw doesn't have this definition, so let's declare it here locally */ typedef int (WINAPI *uv_sGetHostNameW) |