2008.08.25 06:28 "Re: [Tiff] creating sparse files......", by Andrey Kiselev
My primary concern about this issue is a portability. I am not sure this approach is totally portable even across the POSIX-compatible systems (and there are multiple levels of compatibility, that is what is the certification for). Also I think the compression will better results overall. Fast methods, such as LZW and Packbits should be great for this particular purpose.
Despite of that it is possible to add such a functionality to libtiff. It can be user-controlled using the TIFFOpen() parameter, just like we are controlling memory-mapped files usage. If not enabled this code path should not be used at all. On some systems it should be disabled during the compile time, just like it is for memory-mapping. Our documentation states:
M Enable the use of memory-mapped files for images opened read-
only. If the underlying system does not support memory-mapped
files or if the specific image being opened cannot be memory-
mapped then the library will fallback to using the normal system
interface for reading information. By default the library will
attempt to use memory-mapped files.
We can use the same approach with the sparse files, though it should be disabled by default.
Roger, if you like to see this in libtiff, please, prepare the patch and submit it via our Bugzilla. But I would like to see it tested under various conditions, the FAT and network file systems are mandatory, I see there is a small likelihood of accidental data loss.
The flag 's' ('sparse') seems to be free for usage in TIFFOpen().
Andrey V. Kiselev