aboutsummaryrefslogtreecommitdiff
path: root/core/path/filepath
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2025-01-18 22:07:19 +0100
committerLaytan Laats <laytanlaats@hotmail.com>2025-01-18 22:23:44 +0100
commite4892f1bb232bbad0795a94f809f3124620653a9 (patch)
tree588e5f69aa996c99b4fc096933e4f1d4776c24be /core/path/filepath
parent47030501abbdb9b09baf34f1ea1ed15f513ccd6d (diff)
os/os2: wasi target support
Diffstat (limited to 'core/path/filepath')
-rw-r--r--core/path/filepath/match.odin1
-rw-r--r--core/path/filepath/path_wasi.odin36
-rw-r--r--core/path/filepath/walk.odin1
3 files changed, 38 insertions, 0 deletions
diff --git a/core/path/filepath/match.odin b/core/path/filepath/match.odin
index 003f8046d..1f0ac9287 100644
--- a/core/path/filepath/match.odin
+++ b/core/path/filepath/match.odin
@@ -1,3 +1,4 @@
+#+build !wasi
package filepath
import "core:os"
diff --git a/core/path/filepath/path_wasi.odin b/core/path/filepath/path_wasi.odin
new file mode 100644
index 000000000..74cc6ca1e
--- /dev/null
+++ b/core/path/filepath/path_wasi.odin
@@ -0,0 +1,36 @@
+package filepath
+
+import "base:runtime"
+
+import "core:strings"
+
+SEPARATOR :: '/'
+SEPARATOR_STRING :: `/`
+LIST_SEPARATOR :: ':'
+
+is_reserved_name :: proc(path: string) -> bool {
+ return false
+}
+
+is_abs :: proc(path: string) -> bool {
+ return strings.has_prefix(path, "/")
+}
+
+abs :: proc(path: string, allocator := context.allocator) -> (string, bool) {
+ if is_abs(path) {
+ return strings.clone(string(path), allocator), true
+ }
+
+ return path, false
+}
+
+join :: proc(elems: []string, allocator := context.allocator) -> (joined: string, err: runtime.Allocator_Error) #optional_allocator_error {
+ for e, i in elems {
+ if e != "" {
+ runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator)
+ p := strings.join(elems[i:], SEPARATOR_STRING, context.temp_allocator) or_return
+ return clean(p, allocator)
+ }
+ }
+ return "", nil
+}
diff --git a/core/path/filepath/walk.odin b/core/path/filepath/walk.odin
index 51dfa71d2..53b10eed7 100644
--- a/core/path/filepath/walk.odin
+++ b/core/path/filepath/walk.odin
@@ -1,3 +1,4 @@
+#+build !wasi
package filepath
import "core:os"