Operating System - HP-UX
1826215 Members
2785 Online
109691 Solutions
New Discussion

fseek with over 2G file problem

 
SOLVED
Go to solution
j773303
Super Advisor

fseek with over 2G file problem

Does anyone has the experience about fseek support over 2G file? I have try to use fseeko() to seek file over 2G, but it get the wrong bytes. Anyone knows fseek or fseeko support file over 2G ? Thanks .
Hero
2 REPLIES 2
T G Manikandan
Honored Contributor
Solution

Re: fseek with over 2G file problem

Hi,

Just make sure

1.File system which supports large files.

2.When you compile use the '_LARGEFILE_SOURCE' option

3.Then use fseeko() and ftello() functions.

Ermin Borovac
Honored Contributor

Re: fseek with over 2G file problem

See the following white paper for full discussion.

HP-UX Large Files White Paper Version 1.4
http://docs.hp.com/en/940/lgfiles4.pdf

To confuse things further ...

Q: Having studied the white paper on Large file support with HP-UX, I am confused by the discussion of the preprocessor macros _LARGEFILE_SOURCE, _LARGEFILE64_SOURCE and _FILE_OFFSET_BITS. Can you summarize their significance for me please?

Use _FILE_OFFSET_BITS=64 if you have a POSIX compliant app that does not use ftell or fseek, and you want to compile for large file access. This has the effect of mapping all the regular calls like 'open' to 'open64' etc. Use _FILE_OFFSET_BITS=64 and _LARGEFILE64_SOURCE if you have a POSIX compliant app that does use ftell and/or fseek. This will result in the calls to ftell/fseek being transformed into ftello64/fseeko64 which are HP extensions allowing these functions to use a file offset beyond the POSIX mandated long data type. _LARGEFILE_SOURCE would map ftell/fseek to ftello/fseeko respectively, the 32-bit versions of these function calls. If you wish to mix 32 and 64 bit calls in the same binary, e.g reading from a 32-bit file and writing to a 64-bit one, you should use (e.g.) lseek and lseek64 explicitly and turn on the _LARGEFILE64_SOURCE macro when compiling.