mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 03:10:06 +00:00
Remove the read_entire_file from the crypto utils and now use the one within core:os
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user