I have some kind of reader which only has a handle (FILE*) to a file. Another process keeps writing to a the same file which I don't have control.
Now, as the other process appends images to that file, it is likely that soon the file size will cross 4 GB limit.
The reader process reads that file using the handle, offset and length of the image file which can be found from some DB.
My question is how would reader be able to read the chunk from the file which will be present after 4GB size.
I'm working on Win32 machine.
EDIT: I'm working on FreeBSD machine as well.
Just use the standard C API on Windows, fread
, fwrite
work just fine on large files. You will need _fseeki64
to seek to a 64-bit position.
You can alternatively use the plain WinAPI (ReadFile
, etc.) which can also deal with >4 GiB files without problems.
[Edit]: The only thing you really need is a 64-bit seek, which ReadFile
provides via the OVERLAPPED
structure (as some commenters mentioned.) You can of course also get by using SetFilePointer
which is the equivalent of _fseeki64
. Reading/Writing is never a problem, no matter the file size, only seeking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With