aboutsummaryrefslogtreecommitdiff
path: root/std/os
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-03 04:55:16 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-03 04:55:49 -0500
commit36ff26609b1d81a253053e7d7785392fae240dab (patch)
tree5226307e3861ac8d9c944ffa611a84f6205a55a6 /std/os
parent6281a511e130aeb4f7c777de9b90c60d7c8c6f34 (diff)
downloadzig-36ff26609b1d81a253053e7d7785392fae240dab.tar.gz
zig-36ff26609b1d81a253053e7d7785392fae240dab.zip
fix self hosted compiler on windows
Diffstat (limited to 'std/os')
-rw-r--r--std/os/index.zig4
-rw-r--r--std/os/path.zig8
2 files changed, 10 insertions, 2 deletions
diff --git a/std/os/index.zig b/std/os/index.zig
index 0fd3f02e9a..e1b6a9dcce 100644
--- a/std/os/index.zig
+++ b/std/os/index.zig
@@ -851,7 +851,7 @@ pub fn makePath(allocator: &Allocator, full_path: []const u8) -> %void {
// march end_index backward until next path component
while (true) {
end_index -= 1;
- if (resolved_path[end_index] == '/')
+ if (os.path.isSep(resolved_path[end_index]))
break;
}
continue;
@@ -864,7 +864,7 @@ pub fn makePath(allocator: &Allocator, full_path: []const u8) -> %void {
// march end_index forward until next path component
while (true) {
end_index += 1;
- if (end_index == resolved_path.len or resolved_path[end_index] == '/')
+ if (end_index == resolved_path.len or os.path.isSep(resolved_path[end_index]))
break;
}
}
diff --git a/std/os/path.zig b/std/os/path.zig
index 9417cb4299..fda1f60811 100644
--- a/std/os/path.zig
+++ b/std/os/path.zig
@@ -22,6 +22,14 @@ pub const delimiter = if (is_windows) delimiter_windows else delimiter_posix;
const is_windows = builtin.os == builtin.Os.windows;
+pub fn isSep(byte: u8) -> bool {
+ if (is_windows) {
+ return byte == '/' or byte == '\\';
+ } else {
+ return byte == '/';
+ }
+}
+
/// Naively combines a series of paths with the native path seperator.
/// Allocates memory for the result, which must be freed by the caller.
pub fn join(allocator: &Allocator, paths: ...) -> %[]u8 {