diff options
| author | Laytan <laytanlaats@hotmail.com> | 2024-10-28 19:21:16 +0100 |
|---|---|---|
| committer | Laytan <laytanlaats@hotmail.com> | 2024-10-28 19:21:16 +0100 |
| commit | 0b4a4212bbd156ab8c2ce3345feb1d9ef859b629 (patch) | |
| tree | 570841d05aee9acb7969524d79c32fd768f04c5b /core/path/filepath | |
| parent | afed3ce6b5ae00d12e46f2799f16e286369ef3b3 (diff) | |
clean up dynlib and path/filepath with sys/posix
Diffstat (limited to 'core/path/filepath')
| -rw-r--r-- | core/path/filepath/path_unix.odin | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/core/path/filepath/path_unix.odin b/core/path/filepath/path_unix.odin index a18dc739e..35b98a7ae 100644 --- a/core/path/filepath/path_unix.odin +++ b/core/path/filepath/path_unix.odin @@ -1,14 +1,10 @@ #+build linux, darwin, freebsd, openbsd, netbsd package filepath -when ODIN_OS == .Darwin { - foreign import libc "system:System.framework" -} else { - foreign import libc "system:c" -} - import "base:runtime" + import "core:strings" +import "core:sys/posix" SEPARATOR :: '/' SEPARATOR_STRING :: `/` @@ -28,11 +24,11 @@ abs :: proc(path: string, allocator := context.allocator) -> (string, bool) { rel = "." } rel_cstr := strings.clone_to_cstring(rel, context.temp_allocator) - path_ptr := realpath(rel_cstr, nil) + path_ptr := posix.realpath(rel_cstr, nil) if path_ptr == nil { - return "", __error()^ == 0 + return "", posix.errno() == nil } - defer _unix_free(rawptr(path_ptr)) + defer posix.free(path_ptr) path_str := strings.clone(string(path_ptr), allocator) return path_str, true @@ -48,26 +44,3 @@ join :: proc(elems: []string, allocator := context.allocator) -> (joined: string } return "", nil } - -@(private) -foreign libc { - realpath :: proc(path: cstring, resolved_path: [^]byte = nil) -> cstring --- - @(link_name="free") _unix_free :: proc(ptr: rawptr) --- - -} -when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD { - @(private) - foreign libc { - @(link_name="__error") __error :: proc() -> ^i32 --- - } -} else when ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD { - @(private) - foreign libc { - @(link_name="__errno") __error :: proc() -> ^i32 --- - } -} else { - @(private) - foreign libc { - @(link_name="__errno_location") __error :: proc() -> ^i32 --- - } -} |