Products > Programming
Open large files on 32-bit OS and ANSI C
Karel:
Using ANSI C, is there already a way to read/write large files (> 2.1 4.2GB) on a 32-bit OS?
ledtester:
It will depend on the OS.
For Linux/Unix I found this:
Portable support for large files
https://stackoverflow.com/a/30867832
which points to calls such as fseeko(), ftello(), fseeko64(), ftello64() and lseek64().
For WinXP SP2 you have the Set/GetFilePointerEx() pair of calls.
Karel:
--- Quote from: ledtester on August 27, 2023, 01:45:40 pm ---It will depend on the OS.
For Linux/Unix I found this:
Portable support for large files
https://stackoverflow.com/a/30867832
which points to calls such as fseeko(), ftello(), fseeko64(), ftello64() and lseek64().
For WinXP SP2 you have the Set/GetFilePointerEx() pair of calls.
--- End quote ---
It's not ANSI C
ejeffrey:
Yes. You can fopen() a file of any size and read it continuously until EOF.
What you can't do is fseek() in a single step. Although technically you can call fseek(fh, LONG_MAX, SEEK_CUR) in a loop to advance to an arbitrary position.
Karel:
--- Quote from: ejeffrey on August 27, 2023, 03:13:37 pm ---Yes. You can fopen() a file of any size and read it continuously until EOF.
What you can't do is fseek() in a single step. Although technically you can call fseek(fh, LONG_MAX, SEEK_CUR) in a loop to advance to an arbitrary position.
--- End quote ---
Interesting. But the limitation of fseek(0 and ftell() seems cumbersome.
It's weird that ANSI C has never been updated with 64-bit variants (that work on 32-bit hosts).
Navigation
[0] Message Index
[#] Next page
Go to full version