aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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})