in reply to Integer overflow in -s or file stat results
It'll probably suffer the same flaw, but you could try POSIX::lseek with SEEK_END and an offset of 0. If successful it returns the byte offset of the position it reached.
If it was really important to avoid system, you could step through the file using seek() with SEEK_CUR and a relative offset of 2**31 (remembering how many steps) and reading a byte until the read fails; then step back to the last good position and do a binary chop until you find the last position at which you can read a byte.
All in all, system is almost certainly preferable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Integer overflow in -s or file stat results
by Laurent_R (Canon) on Mar 07, 2017 at 18:30 UTC |