Always open files on Windows as sparse files.

GitOrigin-RevId: 93a01f926970045e5db78e16f21eab293822b3be
This commit is contained in:
levlam 2020-01-02 20:18:55 +03:00
parent 580530b6d4
commit 12ab53bdfa

View File

@ -206,6 +206,12 @@ Result<FileFd> FileFd::open(CSlice filepath, int32 flags, int32 mode) {
if (handle == INVALID_HANDLE_VALUE) {
return OS_ERROR(PSLICE() << "File \"" << filepath << "\" can't be " << PrintFlags{flags});
}
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
if (flags & Write) {
DWORD bytes_returned = 0;
DeviceIoControl(handle, FSCTL_SET_SPARSE, nullptr, 0, nullptr, 0, &bytes_returned, nullptr);
}
#endif
auto native_fd = NativeFd(handle);
if (flags & Append) {
LARGE_INTEGER offset;