From 0403626acf1c631b20d551d9aef4fb8cb2afd29f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 23 Jul 2024 15:57:17 +0100 Subject: [PATCH] Add utility calls to os2 --- core/os/os2/errors.odin | 2 ++ core/os/os2/stat.odin | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/core/os/os2/errors.odin b/core/os/os2/errors.odin index 8961bf599..2b9b3528e 100644 --- a/core/os/os2/errors.odin +++ b/core/os/os2/errors.odin @@ -39,6 +39,8 @@ Error :: union #shared_nil { } #assert(size_of(Error) == size_of(u64)) +ERROR_NONE :: Error{} + is_platform_error :: proc(ferr: Error) -> (err: i32, ok: bool) { diff --git a/core/os/os2/stat.odin b/core/os/os2/stat.odin index fad33da0a..cfc362d77 100644 --- a/core/os/os2/stat.odin +++ b/core/os/os2/stat.odin @@ -54,3 +54,21 @@ stat_do_not_follow_links :: proc(name: string, allocator: runtime.Allocator) -> same_file :: proc(fi1, fi2: File_Info) -> bool { return _same_file(fi1, fi2) } + + +last_write_time :: modification_time +last_write_time_by_name :: modification_time_by_name + +@(require_results) +modification_time :: proc(f: ^File) -> (time.Time, Error) { + TEMP_ALLOCATOR_GUARD() + fi, err := fstat(f, temp_allocator()) + return fi.modification_time, err +} + +@(require_results) +modification_time_by_name :: proc(path: string) -> (time.Time, Error) { + TEMP_ALLOCATOR_GUARD() + fi, err := stat(path, temp_allocator()) + return fi.modification_time, err +}