X-Account-Key: account1
X-UIDL: 18c29ce9b7475d3b18a0949f87561965
X-Mozilla-Status: 0011
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Received: from lists.maptools.org (localhost [127.0.0.1])
	by mail.howardsilvan.com (Postfix) with ESMTPS id C4F62C4214D
	for <faxguy@howardsilvan.com>; Mon, 11 Jan 2016 06:20:25 -0800 (PST)
Received: from lists.maptools.org ([94.23.4.142] helo=lists.maptools.org)
	by fangorn.howardsilvan.com with SMTP (2.3.3); 11 Jan 2016 06:20:24 -0800
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id E49A935C0DE;
	Mon, 11 Jan 2016 09:19:19 -0500 (EST)
Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41])
	by lists.maptools.org (Postfix) with ESMTPS id 0D45335C0F8
	for <tiff@lists.maptools.org>; Mon, 11 Jan 2016 09:18:38 -0500 (EST)
Received: by mail-wm0-f41.google.com with SMTP id f206so270833595wmf.0
	for <tiff@lists.maptools.org>; Mon, 11 Jan 2016 06:18:38 -0800 (PST)
MIME-Version: 1.0
X-Received: by 10.28.186.85 with SMTP id k82mr15068338wmf.77.1452521918205;
	Mon, 11 Jan 2016 06:18:38 -0800 (PST)
Received: by 10.27.13.148 with HTTP; Mon, 11 Jan 2016 06:18:38 -0800 (PST)
In-Reply-To: <3F7B3A750517124893CF96FCDAAE6B690EFBE150@Exchange.ffei.local>
References: <3F7B3A750517124893CF96FCDAAE6B690EFBE150@Exchange.ffei.local>
Date: Mon, 11 Jan 2016 09:18:38 -0500
Message-ID: <CAAcuQeZtj0sexBKoivzx7E04Psea+1teNPAJ-P_ee5Mtnarivg@mail.gmail.com>
From: Olivier Paquet <olivier.paquet@gmail.com>
To: John Stevenson-Hoare <John.Stevenson-Hoare@ffei.co.uk>
Cc: "tiff@lists.maptools.org" <tiff@lists.maptools.org>
Subject: Re: [Tiff] Problem with TIFFCurrentDirectory
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-Assp-ID: fangorn.howardsilvan.com m1-22025-12617
X-Assp-Session: 7F06EEFEB0E0 (mail 1)
X-Assp-Detected-RIP: 74.125.82.41
X-Assp-Source-IP: 74.125.82.41
X-Assp-Envelope-From: tiff-bounces@lists.maptools.org
X-Assp-Intended-For: faxguy@howardsilvan.com
X-Assp-Version: 2.3.3(14029) on fangorn.howardsilvan.com
X-Assp-Server-TLS: yes
X-Assp-Delay: not delayed (whitelisted); 11 Jan 2016 06:20:25 -0800
X-Assp-Whitelisted: Yes (whitelistdb)
Return-Path: tiff-bounces@lists.maptools.org
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

2016-01-11 6:19 GMT-05:00 John Stevenson-Hoare
<John.Stevenson-Hoare@ffei.co.uk>:
> The man pages state that directories are indexed from 0, but when I create a new TIFF and invoke TIFFCurrentDirectory the return value is 65535. Is this a bug?

I would say yes but it has been around for so long that there might be
applications depending on it. The counter is set to -1 initially and
incremented when a directory is read. But it is incremented only after
directories are written so it's always late by 1 when writing a new
file. As far as I could see, the code dates back to the origin of the
CVS repo (1999). It might have been done that way on purpose... but I
can't see why and it's certainly confusing.

Directories are indeed counted from 0 so your best way out is probably
to just count them yourself when writing for now.

> My problem is that I need to cache the indexes of directories as I create them so that I can re-visit and update them. If I do this with a file containing 2 directories (both tiled images) the library reports:

That's an entirely different problem. libtiff wasn't really designed
for that kind of use but it might be possible to do what you want,
with some constraints. See the mailing list archive for February 2015.

Olivier Paquet
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/


