How to check whether a file/chunk is all zeros

551 Views Asked by At

I have written some software that reads a proprietary file system's index and then writes the files to a new location (see here for more info if interested).

Since successfully using the software, I have noticed that some blocks pointed at by the file system actually contain no data anymore and are filled with zeros. The way I've written the software so far results in zero byte files being written to the length of the default block size of the file system (typically 1GB).

I'd like an efficient method for checking whether a block is entirely filled with zeros before it is written as a file. My first idea is to simply use the find function of bitstring to look for a 1 bit and then to return True that the block has data.

Is there a more efficient method?

0

There are 0 best solutions below