You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support large files in FileReader on Windows (#1490)
### Changelog
* C++: Support reading files of size 2GiB+ using `FileReader` on
Windows.
### Docs
None
### Description
`fseek` and `ftell` use `long` for offsets, which is a signed 32-bit
integer even on 64-bit Windows. This limited `FileReader` to files of
size 2^31 - 1. When getting the file's size, larger files would cause
`ftell` to return -1 (indicating an error). The return value was not
checked, and this was cast to `uint64_t`, wrapping the value to 2^64 -
1. This PR changes the implementation to instead use the
Windows-specific `_ftelli64` and `_fseeki64` which take an `__int64`
instead, and also to check the return values.
This PR also means that 32-bit POSIX platforms will now cause the
`FileReader` constructor to throw an exception when passed a file of
size 2GiB+ rather than running into the same problem.
I have added a `FileReader` unit test generating a large sparse file and
checked that it fails without the change to `FileReader`.
Fixes#1486.
Fixes: FIRE-221
0 commit comments