[gdal-dev] Quick dataset close

Frank Warmerdam warmerdam at pobox.com
Wed Sep 22 10:15:49 EDT 2010


Christiaan Janssen wrote:
> Is there a way to quickly close a large dataset using the API? For 
> instance, I'm writing to very large TIFF file at which point the user 
> cancels, the code in turn stops what it's doing, closes the dataset, and 
> deletes the file. The problem is, since the file is around 5GB the close 
> dataset function will flush out the remaining file since it believes I'm 
> done writing, where in reality I would prefer it to just close it, 
> leaving it in an invalid state, so I can promptly delete it (or GDAL 
> could close and delete it itself if it wanted doesn't matter to me). Thanks.

Christian,

I'm not aware of a way of doing this with the current GDAL API.  If you wanted
to modify the code a bit you could expose TryGetLockedBlockRef() on the
GDALRasterBand.  Then walk all the blocks trying to fetch them - it will only
work if they are in the cache.  When you get one call MarkClean() on it.
When this is done for all blocks, you can delete the dataset object without
it attempting to flush out the blocks.

Potentially we could add a DiscardPendingWrites() method on the GDALRasterBlock
that would do this but the need seems pretty special purpose so I'm not too
inclined to pursue it.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list