update fileHash

the actual function reads a line at a time instead of in fixed chunks,
but this is fine
master
magical 2024-02-03 01:35:48 -08:00
parent 12a22c8724
commit e7a5af202a
1 changed files with 13 additions and 9 deletions

View File

@ -35,15 +35,19 @@ version = '0.11.6'
def ceiling(num, denom):
return -(num // -denom)
def fileHash(fileName):
with open(fileName, 'rb') as fh:
hash = 0
while True:
s = fh.read(65536)
if not s:
break
hash = zlib.crc32(s, hash)
return (hash & 0xFFFFFFFF)
def fileHash(file):
checksum = 0
try:
with open(file, 'rb') as source:
while True:
s = source.read(65536)
if not s:
break
checksum = zlib.crc32(s, checksum)
except FileNotFoundError:
sys.exit('Error:', file, 'could not be opened.')
return checksum & 0xFFFFFFFF
def enable_item(graph, item):
globals()[item] = True