From f3b7123c0e753533d64e8b28bbcc036a3e3a8ad6 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 28 Oct 2025 00:40:07 +0100 Subject: [PATCH] Convert `core:encoding/hxa` --- core/encoding/hxa/read.odin | 8 ++++---- core/encoding/hxa/write.odin | 6 +++--- tests/core/encoding/hxa/test_core_hxa.odin | 6 ++---- tests/core/normal.odin | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/core/encoding/hxa/read.odin b/core/encoding/hxa/read.odin index 6dde16848..04dcab817 100644 --- a/core/encoding/hxa/read.odin +++ b/core/encoding/hxa/read.odin @@ -1,7 +1,7 @@ package encoding_hxa import "core:fmt" -import "core:os" +import os "core:os/os2" import "core:mem" Read_Error :: enum { @@ -14,13 +14,13 @@ Read_Error :: enum { read_from_file :: proc(filename: string, print_error := false, allocator := context.allocator, loc := #caller_location) -> (file: File, err: Read_Error) { context.allocator = allocator - data, ok := os.read_entire_file(filename, allocator, loc) - if !ok { + data, data_err := os.read_entire_file(filename, allocator) + if data_err != nil { err = .Unable_To_Read_File delete(data, allocator, loc) return } - file, err = read(data, filename, print_error, allocator, loc) + file, err = read(data, filename, print_error, allocator) file.backing = data return } diff --git a/core/encoding/hxa/write.odin b/core/encoding/hxa/write.odin index 5bb950e81..e8ef9a139 100644 --- a/core/encoding/hxa/write.odin +++ b/core/encoding/hxa/write.odin @@ -1,7 +1,7 @@ package encoding_hxa -import "core:os" -import "core:mem" +import os "core:os/os2" +import "core:mem" Write_Error :: enum { None, @@ -18,7 +18,7 @@ write_to_file :: proc(filepath: string, file: File) -> (err: Write_Error) { defer delete(buf) write_internal(&Writer{data = buf}, file) - if !os.write_entire_file(filepath, buf) { + if os.write_entire_file(filepath, buf) != nil { err =.Failed_File_Write } return diff --git a/tests/core/encoding/hxa/test_core_hxa.odin b/tests/core/encoding/hxa/test_core_hxa.odin index a8f3e94f6..7f495e161 100644 --- a/tests/core/encoding/hxa/test_core_hxa.odin +++ b/tests/core/encoding/hxa/test_core_hxa.odin @@ -9,17 +9,15 @@ import "core:testing" TEAPOT_PATH :: ODIN_ROOT + "tests/core/assets/HXA/teapot.hxa" -import "core:os" +import os "core:os/os2" @test test_read :: proc(t: ^testing.T) { - data, _ := os.read_entire_file(TEAPOT_PATH) - // file, err := hxa.read_from_file(TEAPOT_PATH) + data, _ := os.read_entire_file(TEAPOT_PATH, context.allocator) file, err := hxa.read(data) file.backing = data file.allocator = context.allocator hxa.file_destroy(file) - // fmt.printfln("%#v", file) e :: hxa.Read_Error.None testing.expectf(t, err == e, "read_from_file(%v) -> %v != %v", TEAPOT_PATH, err, e) diff --git a/tests/core/normal.odin b/tests/core/normal.odin index 902b81f1b..87a4cf27f 100644 --- a/tests/core/normal.odin +++ b/tests/core/normal.odin @@ -52,4 +52,4 @@ download_assets :: proc "contextless" () { @(require) import "text/regex" @(require) import "thread" @(require) import "time" -@(require) import "unicode" +@(require) import "unicode" \ No newline at end of file