fix conflict

This commit is contained in:
Jeroen van Rijn
2026-02-08 12:42:17 +01:00
parent 7b18a08d56
commit ec314c8324

View File

@@ -2,25 +2,25 @@
package crypto_hash
import "core:io"
import "core:os"
import os "core:os/os2"
// hash_file will read the file provided by the given handle and return the
// `hash_file` will read the file provided by the given handle and return the
// computed digest in a newly allocated slice.
hash_file :: proc(
algorithm: Algorithm,
hd: os.Handle,
hash_file_by_handle :: proc(
algorithm: Algorithm,
handle: ^os.File,
load_at_once := false,
allocator := context.allocator,
allocator := context.allocator,
) -> (
[]byte,
io.Error,
) {
if !load_at_once {
return hash_stream(algorithm, os.stream_from_handle(hd), allocator)
return hash_stream(algorithm, handle.stream, allocator)
}
buf, ok := os.read_entire_file(hd, allocator)
if !ok {
buf, err := os.read_entire_file(handle, allocator)
if err != nil {
return nil, io.Error.Unknown
}
defer delete(buf, allocator)
@@ -28,11 +28,30 @@ hash_file :: proc(
return hash_bytes(algorithm, buf, allocator), io.Error.None
}
hash_file_by_name :: proc(
algorithm: Algorithm,
filename: string,
load_at_once := false,
allocator := context.allocator,
) -> (
[]byte,
io.Error,
) {
handle, err := os.open(filename)
defer os.close(handle)
if err != nil {
return {}, io.Error.Unknown
}
return hash_file_by_handle(algorithm, handle, load_at_once, allocator)
}
hash :: proc {
hash_stream,
hash_file,
hash_file_by_handle,
hash_bytes,
hash_string,
hash_bytes_to_buffer,
hash_string_to_buffer,
}
}