|
Packit |
994f1a |
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3.2.1 2010-06-08 18:50:42 bfriesen Exp $ */
|
|
Packit |
994f1a |
|
|
Packit |
994f1a |
/*
|
|
Packit |
994f1a |
* Copyright (c) 1988-1997 Sam Leffler
|
|
Packit |
994f1a |
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
Packit |
994f1a |
*
|
|
Packit |
994f1a |
* Permission to use, copy, modify, distribute, and sell this software and
|
|
Packit |
994f1a |
* its documentation for any purpose is hereby granted without fee, provided
|
|
Packit |
994f1a |
* that (i) the above copyright notices and this permission notice appear in
|
|
Packit |
994f1a |
* all copies of the software and related documentation, and (ii) the names of
|
|
Packit |
994f1a |
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
Packit |
994f1a |
* publicity relating to the software without the specific, prior written
|
|
Packit |
994f1a |
* permission of Sam Leffler and Silicon Graphics.
|
|
Packit |
994f1a |
*
|
|
Packit |
994f1a |
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
994f1a |
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
Packit |
994f1a |
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
994f1a |
*
|
|
Packit |
994f1a |
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
Packit |
994f1a |
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
Packit |
994f1a |
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
Packit |
994f1a |
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
Packit |
994f1a |
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
Packit |
994f1a |
* OF THIS SOFTWARE.
|
|
Packit |
994f1a |
*/
|
|
Packit |
994f1a |
|
|
Packit |
994f1a |
/*
|
|
Packit |
994f1a |
* TIFF Library.
|
|
Packit |
994f1a |
*/
|
|
Packit |
994f1a |
#include "tiffiop.h"
|
|
Packit |
994f1a |
|
|
Packit |
994f1a |
int
|
|
Packit |
994f1a |
TIFFFlush(TIFF* tif)
|
|
Packit |
994f1a |
{
|
|
Packit |
994f1a |
|
|
Packit |
994f1a |
if (tif->tif_mode != O_RDONLY) {
|
|
Packit |
994f1a |
if (!TIFFFlushData(tif))
|
|
Packit |
994f1a |
return (0);
|
|
Packit |
994f1a |
if ((tif->tif_flags & TIFF_DIRTYDIRECT) &&
|
|
Packit |
994f1a |
!TIFFWriteDirectory(tif))
|
|
Packit |
994f1a |
return (0);
|
|
Packit |
994f1a |
}
|
|
Packit |
994f1a |
return (1);
|
|
Packit |
994f1a |
}
|
|
Packit |
994f1a |
|
|
Packit |
994f1a |
/*
|
|
Packit |
994f1a |
* Flush buffered data to the file.
|
|
Packit |
994f1a |
*
|
|
Packit |
994f1a |
* Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING
|
|
Packit |
994f1a |
* is not set, so that TIFFFlush() will proceed to write out the directory.
|
|
Packit |
994f1a |
* The documentation says returning 1 is an error indicator, but not having
|
|
Packit |
994f1a |
* been writing isn't exactly a an error. Hopefully this doesn't cause
|
|
Packit |
994f1a |
* problems for other people.
|
|
Packit |
994f1a |
*/
|
|
Packit |
994f1a |
int
|
|
Packit |
994f1a |
TIFFFlushData(TIFF* tif)
|
|
Packit |
994f1a |
{
|
|
Packit |
994f1a |
if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
|
|
Packit |
994f1a |
return (0);
|
|
Packit |
994f1a |
if (tif->tif_flags & TIFF_POSTENCODE) {
|
|
Packit |
994f1a |
tif->tif_flags &= ~TIFF_POSTENCODE;
|
|
Packit |
994f1a |
if (!(*tif->tif_postencode)(tif))
|
|
Packit |
994f1a |
return (0);
|
|
Packit |
994f1a |
}
|
|
Packit |
994f1a |
return (TIFFFlushData1(tif));
|
|
Packit |
994f1a |
}
|
|
Packit |
994f1a |
|
|
Packit |
994f1a |
/*
|
|
Packit |
994f1a |
* Local Variables:
|
|
Packit |
994f1a |
* mode: c
|
|
Packit |
994f1a |
* c-basic-offset: 8
|
|
Packit |
994f1a |
* fill-column: 78
|
|
Packit |
994f1a |
* End:
|
|
Packit |
994f1a |
*/
|