/* Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING is not set, so that TIFFFlush() will proceed to write out the directory. The documentation says returning 1 is an error indicator, but not having been writing isn't exactly a an error. Hopefully this doesn't cause problems for other people.  */
int TIFFFlushData(TIFF *tif)
/* Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING is not set, so that TIFFFlush() will proceed to write out the directory. The documentation says returning 1 is an error indicator, but not having been writing isn't exactly a an error. Hopefully this doesn't cause problems for other people.  */
int TIFFFlushData(TIFF *tif)
{
	if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
		return (1);
	if (tif->tif_flags & TIFF_POSTENCODE) {
		tif->tif_flags &= ~TIFF_POSTENCODE;
		if (!(*tif->tif_postencode)(tif))
			return (0);
	}
	return (TIFFFlushData1(tif));
}