Skip to content

Commit

Permalink
fix os.path.resolveWindows on non-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Oct 9, 2017
1 parent 987e0f5 commit 7f56744
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions std/os/path.zig
Expand Up @@ -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{});
}

Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 7f56744

Please sign in to comment.