update fileHash
the actual function reads a line at a time instead of in fixed chunks, but this is finemaster
parent
12a22c8724
commit
e7a5af202a
|
@ -35,15 +35,19 @@ version = '0.11.6'
|
||||||
def ceiling(num, denom):
|
def ceiling(num, denom):
|
||||||
return -(num // -denom)
|
return -(num // -denom)
|
||||||
|
|
||||||
def fileHash(fileName):
|
def fileHash(file):
|
||||||
with open(fileName, 'rb') as fh:
|
checksum = 0
|
||||||
hash = 0
|
try:
|
||||||
|
with open(file, 'rb') as source:
|
||||||
while True:
|
while True:
|
||||||
s = fh.read(65536)
|
s = source.read(65536)
|
||||||
if not s:
|
if not s:
|
||||||
break
|
break
|
||||||
hash = zlib.crc32(s, hash)
|
checksum = zlib.crc32(s, checksum)
|
||||||
return (hash & 0xFFFFFFFF)
|
except FileNotFoundError:
|
||||||
|
sys.exit('Error:', file, 'could not be opened.')
|
||||||
|
return checksum & 0xFFFFFFFF
|
||||||
|
|
||||||
|
|
||||||
def enable_item(graph, item):
|
def enable_item(graph, item):
|
||||||
globals()[item] = True
|
globals()[item] = True
|
||||||
|
|
Loading…
Reference in New Issue