mirror of
https://github.com/holub/mame
synced 2025-06-22 12:28:33 +03:00
chdtest.py: Open as binary, read in chunks to reduce memory usage. (nw)
This commit is contained in:
parent
c8c37ef19c
commit
b32c98689f
@ -30,9 +30,16 @@ def compareInfo(info1, info2):
|
|||||||
def sha1sum(path):
|
def sha1sum(path):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return ""
|
return ""
|
||||||
|
f = open(path, 'rb')
|
||||||
|
try:
|
||||||
sha1 = hashlib.sha1()
|
sha1 = hashlib.sha1()
|
||||||
f = open(path, 'r')
|
while True:
|
||||||
sha1.update(f.read())
|
data = f.read(8192)
|
||||||
|
if data:
|
||||||
|
sha1.update(data)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
return sha1.hexdigest()
|
return sha1.hexdigest()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user