aboutsummaryrefslogtreecommitdiff
path: root/core/path/filepath/path.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-12 13:55:17 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-12 13:55:17 +0100
commit1159110e735ba84d651f4bbc4e9883fd83e9eddc (patch)
tree97d8ebca8da97c0af8159450772bc83f0e8d9f07 /core/path/filepath/path.odin
parent90923272b37293d4dd902e2a53b79209c2dc82a0 (diff)
Fix #6265
Diffstat (limited to 'core/path/filepath/path.odin')
-rw-r--r--core/path/filepath/path.odin15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/path/filepath/path.odin b/core/path/filepath/path.odin
index 58dc06103..a325ce4cd 100644
--- a/core/path/filepath/path.odin
+++ b/core/path/filepath/path.odin
@@ -251,15 +251,22 @@ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> (
*/
dir :: proc(path: string, allocator := context.allocator) -> string {
context.allocator = allocator
- vol := volume_name(path)
+ vol_len := len(volume_name(path))
+ when ODIN_OS == .Windows {
+ if len(path) >= 3 && is_separator(path[2]) {
+ vol_len += 1
+ }
+ }
+ vol := path[:vol_len]
+
i := len(path) - 1
- for i >= len(vol) && !is_separator(path[i]) {
+ for i >= vol_len && !is_separator(path[i]) {
i -= 1
}
- dir, dir_err := clean(path[len(vol) : i+1], allocator)
+ dir, dir_err := clean(path[vol_len : i+1], allocator)
if dir_err != nil { return "" }
defer delete(dir)
- if dir == "." && len(vol) > 2 {
+ if dir == "." && vol_len > 2 {
return strings.clone(vol)
}
return strings.concatenate({vol, dir})