2018.12.11 13:36 "[Tiff] SeekOK and WriteOK", by Emmanuel Cosnard

2018.12.11 14:24 "Re: [Tiff] SeekOK and WriteOK", by Emmanuel Cosnard

It sometimes returns -1 although it seems to have well written what I wanted, and sometimes returns -1 and hasn't written anything.

________________________________

De: Tiff <tiff-bounces@lists.osgeo.org> de la part de Emmanuel Cosnard <emmanuel.cosnard@outlook.fr>

Envoyé: mardi 11 décembre 2018 14:09
À: Bob Friesenhahn

: tiff@lists.osgeo.org
 Objet: Re: [Tiff] SeekOK and WriteOK

Hello Bob,

Thanks for your answer!

I am using windows 64 bits.

Actually, I created my own TIFFWriteData function and I am now sure that it's the WriteOK that doesn't work on some occasion, but still have no idea why.

Best regards,

Emmanuel
________________________________
De: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
Envoyé: mardi 11 décembre 2018 14:01
À: Emmanuel Cosnard
Cc: tiff@lists.osgeo.org
Objet: Re: [Tiff] SeekOK and WriteOK

On Tue, 11 Dec 2018, Emmanuel Cosnard wrote:

> Hello,
>
> I am using the function TIFFWriteData to write some data on a custome rationnal tag, and it seems, that on some rare occasion,
> if (SeekOK(tif, dir->tdir_offset) && WriteOK(tif, cp, cc))
> Is there a way to do some intelligent retry here, instead of returning an error? Or can we know why the WriteOK or SeekOK didn't work properly?

You did not mention the operating system you are using or the size of
its native off_t type (or equivalent). It might make a difference if
you are using tif_unix.c or tif_win32.c, and the capabilities of the
compiler and run-time when the library was compiled.

This is the underlying implementation of the check:

int _TIFFSeekOK(TIFF* tif, toff_t off)
{
     /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
     /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
     return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off;
}

One can see that the first check is that the offset must be within the
range of a signed 64-bit type. The next check actually does the seek
and checks if the requested position was obtained. This is a case
where the seek position might need to be in the range of a smaller
size.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt