From 509da8e63234c5d30082301d5054f9441a7d0912 Mon Sep 17 00:00:00 2001 From: sh!zeeg Date: Fri, 10 Jan 2025 05:56:56 +0300 Subject: [PATCH] add os.exists() to FreeBSD --- core/os/os_freebsd.odin | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index 837e79f4de3..87a56b05729 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -624,6 +624,14 @@ is_dir_path :: proc(path: string, follow_links: bool = true) -> bool { is_file :: proc {is_file_path, is_file_handle} is_dir :: proc {is_dir_path, is_dir_handle} +@(require_results) +exists :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + cpath := strings.clone_to_cstring(path, context.temp_allocator) + res := _unix_access(cpath, O_RDONLY) + return res == 0 +} + // NOTE(bill): Uses startup to initialize it stdin: Handle = 0