From 7f56744320139ef134658f9ee756050345a31d30 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 8 Oct 2017 21:52:26 -0400 Subject: [PATCH] fix os.path.resolveWindows on non-windows --- std/os/path.zig | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/std/os/path.zig b/std/os/path.zig index eea0df461a..f83744785a 100644 --- a/std/os/path.zig +++ b/std/os/path.zig @@ -177,9 +177,14 @@ test "os.path.networkShare" { } pub fn diskDesignator(path: []const u8) -> []const u8 { - if (!is_windows) + if (is_windows) { + return diskDesignatorWindows(path); + } else { return ""; + } +} +pub fn diskDesignatorWindows(path: []const u8) -> []const u8 { return drive(path) ?? (networkShare(path) ?? []u8{}); } @@ -334,7 +339,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8 mem.copy(u8, result, cwd); result_index += cwd.len; - root_slice = diskDesignator(result[0..result_index]); + root_slice = diskDesignatorWindows(result[0..result_index]); } %defer allocator.free(result); @@ -350,7 +355,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8 continue; } } - var it = mem.split(p[diskDesignator(p).len..], "/\\"); + var it = mem.split(p[diskDesignatorWindows(p).len..], "/\\"); while (it.next()) |component| { if (mem.eql(u8, component, ".")) { continue; @@ -505,7 +510,7 @@ pub fn dirnameWindows(path: []const u8) -> []const u8 { if (path.len == 0) return path[0..0]; - const root_slice = diskDesignator(path); + const root_slice = diskDesignatorWindows(path); if (path.len == root_slice.len) return path;