diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-06-03 20:01:22 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-06-04 11:08:25 +0200 |
| commit | ae5c92ac38dd7facce8a61b110e08b1b4a2a4238 (patch) | |
| tree | 16e78531439db7fce856f93ff4f064647f40eaad /core/path | |
| parent | 986cfbcaf4aa6300109e93c114e439d2578887af (diff) | |
Enable `odin check examples/all` for JS.
Diffstat (limited to 'core/path')
| -rw-r--r-- | core/path/filepath/path_js.odin | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/path/filepath/path_js.odin b/core/path/filepath/path_js.odin new file mode 100644 index 000000000..3b5ac04f5 --- /dev/null +++ b/core/path/filepath/path_js.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 +}
\ No newline at end of file |