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" {...@@ -177,9 +177,14 @@ test "os.path.networkShare" {
177}177}
178178
179pub fn diskDesignator(path: []const u8) -> []const u8 {179pub fn diskDesignator(path: []const u8) -> []const u8 {
180 if (!is_windows)180 if (is_windows) {
181 return diskDesignatorWindows(path);
182 } else {
181 return "";183 return "";
184 }
185}
182186
187pub fn diskDesignatorWindows(path: []const u8) -> []const u8 {
183 return drive(path) ?? (networkShare(path) ?? []u8{});188 return drive(path) ?? (networkShare(path) ?? []u8{});
184}189}
185190
...@@ -334,7 +339,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8...@@ -334,7 +339,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8
334 mem.copy(u8, result, cwd);339 mem.copy(u8, result, cwd);
335 result_index += cwd.len;340 result_index += cwd.len;
336341
337 root_slice = diskDesignator(result[0..result_index]);342 root_slice = diskDesignatorWindows(result[0..result_index]);
338 }343 }
339 %defer allocator.free(result);344 %defer allocator.free(result);
340345
...@@ -350,7 +355,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8...@@ -350,7 +355,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8
350 continue;355 continue;
351 }356 }
352 }357 }
353 var it = mem.split(p[diskDesignator(p).len..], "/\\");358 var it = mem.split(p[diskDesignatorWindows(p).len..], "/\\");
354 while (it.next()) |component| {359 while (it.next()) |component| {
355 if (mem.eql(u8, component, ".")) {360 if (mem.eql(u8, component, ".")) {
356 continue;361 continue;
...@@ -505,7 +510,7 @@ pub fn dirnameWindows(path: []const u8) -> []const u8 {...@@ -505,7 +510,7 @@ pub fn dirnameWindows(path: []const u8) -> []const u8 {
505 if (path.len == 0)510 if (path.len == 0)
506 return path[0..0];511 return path[0..0];
507512
508 const root_slice = diskDesignator(path);513 const root_slice = diskDesignatorWindows(path);
509 if (path.len == root_slice.len)514 if (path.len == root_slice.len)
510 return path;515 return path;
511516