authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-08 21:52:26-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-08 21:52:26-04:00
log7f56744320139ef134658f9ee756050345a31d30
tree400ccedf66c239d915df29c3cada0e75cf2ba790
parent987e0f5acb4b16f8b7c10dd4ff43256674bc5065

fix os.path.resolveWindows on non-windows


1 files changed, 9 insertions(+), 4 deletions(-)

std/os/path.zig+9-4
......@@ -177,9 +177,14 @@ test "os.path.networkShare" {
177177}
178178
179179pub fn diskDesignator(path: []const u8) -> []const u8 {
180 if (!is_windows)
180 if (is_windows) {
181 return diskDesignatorWindows(path);
182 } else {
181183 return "";
184 }
185}
182186
187pub fn diskDesignatorWindows(path: []const u8) -> []const u8 {
183188 return drive(path) ?? (networkShare(path) ?? []u8{});
184189}
185190
......@@ -334,7 +339,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8
334339 mem.copy(u8, result, cwd);
335340 result_index += cwd.len;
336341
337 root_slice = diskDesignator(result[0..result_index]);
342 root_slice = diskDesignatorWindows(result[0..result_index]);
338343 }
339344 %defer allocator.free(result);
340345
......@@ -350,7 +355,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8
350355 continue;
351356 }
352357 }
353 var it = mem.split(p[diskDesignator(p).len..], "/\\");
358 var it = mem.split(p[diskDesignatorWindows(p).len..], "/\\");
354359 while (it.next()) |component| {
355360 if (mem.eql(u8, component, ".")) {
356361 continue;
......@@ -505,7 +510,7 @@ pub fn dirnameWindows(path: []const u8) -> []const u8 {
505510 if (path.len == 0)
506511 return path[0..0];
507512
508 const root_slice = diskDesignator(path);
513 const root_slice = diskDesignatorWindows(path);
509514 if (path.len == root_slice.len)
510515 return path;
511516