Skip to content

Instantly share code, notes, and snippets.

@eam
Created November 8, 2018 14:19
Show Gist options
  • Save eam/5d7772df4fa3a53cd1d873c2bd0c5057 to your computer and use it in GitHub Desktop.
Save eam/5d7772df4fa3a53cd1d873c2bd0c5057 to your computer and use it in GitHub Desktop.
def is_zeroed(device_name, buffer_size = 2048):
zero = "\x00"
with open(device_name, "rb") as file:
buffer = file.read(buffer_size)
while buffer != "":
if not all(c == zero for c in buffer):
return False
buffer = file.read(buffer_size)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment