NTFS (like most of nowadays file systems) provides the ability to skip chunks of data with continuous zero bytes because the starting point and a number is important here. Moreover it could be done transparently to all (ok, most) of available software.
Windows is equipped with “fsutil” tool to covert this feature. However ranges of the potentially empty regions with zeros have to be specified manually. And before the the actual sparse range is set file has to be marked as a sparse file with the following command:
fsutil sparse setflag <file_name>
Next, actual sparse regions can be set. For example:
fsutil sparse setrange C:\Temp\sample.txt 65536 131072
Finally the the list of sparse ranges can be obtained :
fsutil sparse queryrange C:\Temp\sample.txt
To check if the file is in fact sparse file the following command has to be executed:
fsutil sparse queryflag C:\Temp\sample.txt
That is it, as for an interface that is being provided out of the box and is present in every Windows instance. In the next snippet I will provide more sophisticated mechanism of “sparse files” management.
- General description: Wikipedia about sparse files
- Really good article on the subject: Sparse files for programmers
- My article and the tool I have written and will cover in the next chapter: SparseChecker