2006.09.21 16:30 "[Tiff] RE: TIFF file bigger than 2Go (Pallek, Bernie: #CIPO - OPIC)", by Phil Harvey

2006.09.22 03:56 "Re: [Tiff] RE: TIFF file bigger than 2Go (Pallek, Bernie: #CIPO - OPIC)", by Graeme Gill

The application I'm developing can't seek past 2GB in a file because the seek() library function takes a signed 4-byte integer. I think this is a common problem. I can read larger files (so a >4GB JPEG image isn't a problem for instance), but due to the TIFF structure, you have to be able to seek to an arbitrary point in the file. So the limit is 2GB. Placing IFD0 first would help, but any data starting after the 2GB point still couldn't be read.

It seems like you might be able to create a fake "seek to unsigned 32 bit offset"

function by doing a signed SEEK_SET to 2G, followed by a SEEK_CUR of the next 2G?

ie., something like:

int fuseek(FILE *fp, unsigned long offset) {
        int rv;
        unsigned long offset;

        if (offset > LONG_MAX) {
                if ((rv = fseek(fp, LONG_MAX, SEEK_SET)) != 0)
                        return rv;
                return fseek(fp, offset - LONG_MAX, SEEK_CUR);
        } else
                return fseek(fp, offset, SEEK_SET);

(although note this doesn't handle the one case where offset = ULONG_MAX)

Graeme Gill.