docs: replace File with FileAccess
This commit is contained in:
@ -11,15 +11,14 @@
|
||||
const CHUNK_SIZE = 102
|
||||
|
||||
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.
|
||||
if not file.file_exists(path):
|
||||
if not FileAccess.file_exists(path):
|
||||
return
|
||||
# Start a SHA-256 context.
|
||||
var ctx = HashingContext.new()
|
||||
ctx.start(HashingContext.HASH_SHA256)
|
||||
# Open the file to hash.
|
||||
file.open(path, File.READ)
|
||||
var file = FileAccess.open(path, FileAccess.READ)
|
||||
# Update the context after reading each chunk.
|
||||
while not file.eof_reached():
|
||||
ctx.update(file.get_buffer(CHUNK_SIZE))
|
||||
|
||||
Reference in New Issue
Block a user