diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-10-28 01:42:45 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2026-02-08 12:42:27 +0100 |
| commit | 170e314f839f013fe58e0c91a61a34c1dbcfecd2 (patch) | |
| tree | 71bbbafd5adfbf64d468bcc146a81abef16b216e /core/image/tga | |
| parent | f63c2094784849ab1ebe1688558e90410af83152 (diff) | |
core:os -> core:os/os for core:image
Diffstat (limited to 'core/image/tga')
| -rw-r--r-- | core/image/tga/tga_os.odin | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/core/image/tga/tga_os.odin b/core/image/tga/tga_os.odin index a78998105..2c103b34a 100644 --- a/core/image/tga/tga_os.odin +++ b/core/image/tga/tga_os.odin @@ -1,34 +1,34 @@ #+build !js package tga -import "core:os" -import "core:bytes" - -save :: proc{save_to_buffer, save_to_file} - -save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { - context.allocator = allocator - - out := &bytes.Buffer{} - defer bytes.buffer_destroy(out) - - save_to_buffer(out, img, options) or_return - write_ok := os.write_entire_file(output, out.buf[:]) - - return nil if write_ok else .Unable_To_Write_File -} +import os "core:os/os2" +import "core:bytes" load :: proc{load_from_file, load_from_bytes, load_from_context} load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { context.allocator = allocator - data, ok := os.read_entire_file(filename) + data, data_err := os.read_entire_file(filename, allocator) defer delete(data) - if ok { + if data_err == nil { return load_from_bytes(data, options) } else { return nil, .Unable_To_Read_File } +} + +save :: proc{save_to_buffer, save_to_file} + +save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { + context.allocator = allocator + + out := &bytes.Buffer{} + defer bytes.buffer_destroy(out) + + save_to_buffer(out, img, options) or_return + write_err := os.write_entire_file(output, out.buf[:]) + + return nil if write_err == nil else .Unable_To_Write_File }
\ No newline at end of file |