docs: replace File with FileAccess

This commit is contained in:
Jiri Suchan
2023-01-30 22:21:36 +08:00
parent 312011fade
commit 4a4adec33d
4 changed files with 10 additions and 16 deletions

View File

@ -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))