From c265d297b5c9252db391cdf43eca079d8f634791 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 30 Oct 2025 13:45:59 +0100 Subject: [PATCH] core:time/timezone -> os2 --- core/time/timezone/tz_unix.odin | 15 +++++++++------ core/time/timezone/tzif.odin | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/core/time/timezone/tz_unix.odin b/core/time/timezone/tz_unix.odin index 542e5c4f2..e4121266d 100644 --- a/core/time/timezone/tz_unix.odin +++ b/core/time/timezone/tz_unix.odin @@ -2,16 +2,16 @@ #+private package timezone -import "core:os" -import "core:strings" -import "core:path/filepath" -import "core:time/datetime" +import os "core:os/os2" +import "core:strings" +import "core:path/filepath" +import "core:time/datetime" local_tz_name :: proc(allocator := context.allocator) -> (name: string, success: bool) { local_str, ok := os.lookup_env("TZ", allocator) if !ok { orig_localtime_path := "/etc/localtime" - path, err := os.absolute_path_from_relative(orig_localtime_path, allocator) + path, err := os.get_absolute_path(orig_localtime_path, allocator) if err != nil { // If we can't find /etc/localtime, fallback to UTC if err == .ENOENT { @@ -28,7 +28,10 @@ local_tz_name :: proc(allocator := context.allocator) -> (name: string, success: // This is a hackaround, because FreeBSD copies rather than softlinks their local timezone file, // *sometimes* and then stores the original name of the timezone in /var/db/zoneinfo instead if path == orig_localtime_path { - data := os.read_entire_file("/var/db/zoneinfo", allocator) or_return + data, data_err := os.read_entire_file("/var/db/zoneinfo", allocator) + if data_err != nil { + return "", false + } return strings.trim_right_space(string(data)), true } diff --git a/core/time/timezone/tzif.odin b/core/time/timezone/tzif.odin index 804211ef4..7a7023c6c 100644 --- a/core/time/timezone/tzif.odin +++ b/core/time/timezone/tzif.odin @@ -1,12 +1,11 @@ package timezone -import "base:intrinsics" - -import "core:slice" -import "core:strings" -import "core:os" -import "core:strconv" -import "core:time/datetime" +import "base:intrinsics" +import "core:slice" +import "core:strings" +import os "core:os/os2" +import "core:strconv" +import "core:time/datetime" // Implementing RFC8536 [https://datatracker.ietf.org/doc/html/rfc8536] @@ -70,7 +69,10 @@ tzif_data_block_size :: proc(hdr: ^TZif_Header, version: TZif_Version) -> (block load_tzif_file :: proc(filename: string, region_name: string, allocator := context.allocator) -> (out: ^datetime.TZ_Region, ok: bool) { - tzif_data := os.read_entire_file_from_filename(filename, allocator) or_return + tzif_data, tzif_err := os.read_entire_file(filename, allocator) + if tzif_err != nil { + return nil, false + } defer delete(tzif_data, allocator) return parse_tzif(tzif_data, region_name, allocator) }