diff --git a/Randomizer.py b/Randomizer.py index ec6db42..946c17a 100644 --- a/Randomizer.py +++ b/Randomizer.py @@ -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