mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 07:43:13 +00:00
Remove the read_entire_file from the crypto utils and now use the one within core:os
This commit is contained in:
@@ -15,7 +15,6 @@ import "core:os"
|
||||
import "core:io"
|
||||
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -272,7 +271,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -313,7 +312,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -354,7 +353,7 @@ hash_file_odin_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -395,7 +394,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import "core:io"
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../_blake2"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -147,7 +146,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import "core:io"
|
||||
|
||||
import "../_ctx"
|
||||
import "../_blake2"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -147,7 +146,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import "core:fmt"
|
||||
import "core:strings"
|
||||
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
hash_bytes_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, data: []byte) -> [16]byte {
|
||||
hash: [16]byte
|
||||
@@ -112,7 +111,7 @@ hash_file_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_16(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_16(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -123,7 +122,7 @@ hash_file_20 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_20(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_20(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -134,7 +133,7 @@ hash_file_24 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_24(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_24(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -145,7 +144,7 @@ hash_file_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -156,7 +155,7 @@ hash_file_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -167,7 +166,7 @@ hash_file_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -178,7 +177,7 @@ hash_file_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load_
|
||||
if !load_at_once {
|
||||
return hash_stream_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -189,7 +188,7 @@ hash_file_128 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, load
|
||||
if !load_at_once {
|
||||
return hash_stream_128(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_128(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -200,7 +199,7 @@ hash_file_slice :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, bi
|
||||
if !load_at_once {
|
||||
return hash_stream_slice(ctx, os.stream_from_handle(hd), bit_size, allocator)
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_slice(ctx, buf[:], bit_size, allocator), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import "core:io"
|
||||
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -140,7 +139,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import "core:os"
|
||||
import "core:io"
|
||||
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -269,7 +268,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -310,7 +309,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -351,7 +350,7 @@ hash_file_odin_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -392,7 +391,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ hash_file_odin_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_16(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_16(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -694,7 +694,7 @@ hash_file_odin_20 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_20(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_20(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -737,7 +737,7 @@ hash_file_odin_24 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_24(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_24(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -780,7 +780,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -823,7 +823,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import "core:os"
|
||||
import "core:io"
|
||||
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -269,7 +268,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -310,7 +309,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -351,7 +350,7 @@ hash_file_odin_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -392,7 +391,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import "core:io"
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../_sha3"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -258,7 +257,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -299,7 +298,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -340,7 +339,7 @@ hash_file_odin_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -381,7 +380,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import "core:os"
|
||||
import "core:io"
|
||||
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -145,7 +144,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ hash_file_odin_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_16(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_16(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ hash_file_odin_20 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_20(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_20(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -363,7 +363,7 @@ hash_file_odin_40 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_40(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_40(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ hash_file_odin_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import "core:io"
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../_sha3"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -258,7 +257,7 @@ hash_file_odin_28 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_28(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_28(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -299,7 +298,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -340,7 +339,7 @@ hash_file_odin_48 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_48(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_48(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -381,7 +380,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import "core:io"
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../_sha3"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -186,7 +185,7 @@ hash_file_odin_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_16(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_16(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -229,7 +228,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import "core:io"
|
||||
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -275,7 +274,7 @@ hash_file_skein256_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Ha
|
||||
if !load_at_once {
|
||||
return hash_stream_skein256_odin(ctx, os.stream_from_handle(hd), bit_size, allocator)
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_skein256_odin(ctx, buf[:], bit_size, allocator), ok
|
||||
}
|
||||
}
|
||||
@@ -320,7 +319,7 @@ hash_file_skein512_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Ha
|
||||
if !load_at_once {
|
||||
return hash_stream_skein512_odin(ctx, os.stream_from_handle(hd), bit_size, allocator)
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_skein512_odin(ctx, buf[:], bit_size, allocator), ok
|
||||
}
|
||||
}
|
||||
@@ -365,7 +364,7 @@ hash_file_skein1024_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.H
|
||||
if !load_at_once {
|
||||
return hash_stream_skein512_odin(ctx, os.stream_from_handle(hd), bit_size, allocator)
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_skein512_odin(ctx, buf[:], bit_size, allocator), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_32(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_32(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_64(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_64(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import "core:io"
|
||||
import "../botan"
|
||||
import "../_ctx"
|
||||
import "../_tiger"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -204,7 +203,7 @@ hash_file_odin_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_16(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_16(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -245,7 +244,7 @@ hash_file_odin_20 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_20(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_20(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -286,7 +285,7 @@ hash_file_odin_24 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_24(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_24(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import "core:io"
|
||||
|
||||
import "../_ctx"
|
||||
import "../_tiger"
|
||||
import "../util"
|
||||
|
||||
/*
|
||||
Context initialization and switching between the Odin implementation and the bindings
|
||||
@@ -204,7 +203,7 @@ hash_file_odin_16 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_16(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_16(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -245,7 +244,7 @@ hash_file_odin_20 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_20(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_20(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
@@ -286,7 +285,7 @@ hash_file_odin_24 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
|
||||
if !load_at_once {
|
||||
return hash_stream_odin_24(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin_24(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ package util
|
||||
*/
|
||||
|
||||
import "core:mem"
|
||||
import "core:os"
|
||||
|
||||
// @note(bp): this can replace the other two
|
||||
cast_slice :: #force_inline proc "contextless" ($D: typeid/[]$DE, src: $S/[]$SE) -> D {
|
||||
@@ -143,28 +142,3 @@ XOR_BUF :: #force_inline proc "contextless" (input, output: []byte) {
|
||||
output[i] ~= input[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Taken from core:os and changed to just take a file handle
|
||||
read_entire_file :: proc(fd: os.Handle, allocator := context.allocator) -> (data: []byte, success: bool) {
|
||||
length: i64
|
||||
err: os.Errno
|
||||
if length, err = os.file_size(fd); err != 0 {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if length <= 0 {
|
||||
return nil, true
|
||||
}
|
||||
|
||||
data = make([]byte, int(length), allocator)
|
||||
if data == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
bytes_read, read_err := os.read(fd, data)
|
||||
if read_err != os.ERROR_NONE {
|
||||
delete(data)
|
||||
return nil, false
|
||||
}
|
||||
return data[:bytes_read], true
|
||||
}
|
||||
@@ -142,7 +142,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
|
||||
if !load_at_once {
|
||||
return hash_stream_odin(ctx, os.stream_from_handle(hd))
|
||||
} else {
|
||||
if buf, ok := util.read_entire_file(hd); ok {
|
||||
if buf, ok := os.read_entire_file(hd); ok {
|
||||
return hash_bytes_odin(ctx, buf[:]), ok
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user