|
@@ -11,15 +11,14 @@
|
|
const CHUNK_SIZE = 102
|
|
const CHUNK_SIZE = 102
|
|
|
|
|
|
func hash_file(path):
|
|
func hash_file(path):
|
|
- var ctx = HashingContext.new()
|
|
|
|
- var file = File.new()
|
|
|
|
- # Start a SHA-256 context.
|
|
|
|
- ctx.start(HashingContext.HASH_SHA256)
|
|
|
|
# Check that file exists.
|
|
# Check that file exists.
|
|
- if not file.file_exists(path):
|
|
|
|
|
|
+ if not FileAccess.file_exists(path):
|
|
return
|
|
return
|
|
|
|
+ # Start a SHA-256 context.
|
|
|
|
+ var ctx = HashingContext.new()
|
|
|
|
+ ctx.start(HashingContext.HASH_SHA256)
|
|
# Open the file to hash.
|
|
# Open the file to hash.
|
|
- file.open(path, File.READ)
|
|
|
|
|
|
+ var file = FileAccess.open(path, FileAccess.READ)
|
|
# Update the context after reading each chunk.
|
|
# Update the context after reading each chunk.
|
|
while not file.eof_reached():
|
|
while not file.eof_reached():
|
|
ctx.update(file.get_buffer(CHUNK_SIZE))
|
|
ctx.update(file.get_buffer(CHUNK_SIZE))
|