Hi,

On Sat, Sep 7, 2013 at 6:44 PM, Marco Schuster <ma...@m-s-d.eu> wrote:

>
> I ran into 32-bit problems, too, when working with >2GB files (in this
> case, raw DVD ISO images) on a 32-bit system (I couldn't find a
> reliable(!!) way to read a 4-byte absolute offset and seek to it).
> Of course, this warning is mentioned in the manpage, but really, not
> having at least a class for unsigned 32-bit ints (e.g. a Uint32 or a
> Uint64 for 64-bit platforms) which native functions like seek and
> friends coerce into a 32/64-bit uint makes PHP useless for anything
> that involves access to files or memory offsets (a problem from
> another project) > 2GB.
>
>
 The seek offset is always signed. In C you have either

int fseek (FILE *stream, long int offset, int whence)

which is signed.

Or you can use
int fseeko (FILE *stream, off_t offset, int whence)
or
off_t lseek(int fd, off_t offset, int whence)
for descriptors.

When you look to glibc, you will find these definitions
#define __OFF_T_TYPE        __SYSCALL_SLONG_TYPE
__STD_TYPE __OFF_T_TYPE __off_t;
typedef __off_t off_t;

__SYSCALL_SLONG_TYPE is signed type as well (S Long :)).

If you  need to seek over 31bit size on 32bit system, then you can seek
twice. Just need to set the whence to SEEK_CUR for the second seek...

Jakub

Reply via email to