| ... | @@ -12,13 +12,19 @@ const fs = std.fs; | ... | @@ -12,13 +12,19 @@ const fs = std.fs; |
| 12 | const process = std.process; | 12 | const process = std.process; |
| 13 | const native_os = builtin.target.os.tag; | 13 | const native_os = builtin.target.os.tag; |
| 14 | | 14 | |
| 15 | pub const sep_windows_uefi = '\\'; | 15 | pub const sep_windows = '\\'; |
| 16 | pub const sep_posix = '/'; | 16 | pub const sep_posix = '/'; |
| 17 | pub const sep = if (native_os == .windows or native_os == .uefi) sep_windows_uefi else sep_posix; | 17 | pub const sep = switch (native_os) { |
| | 18 | .windows, .uefi => sep_windows, |
| | 19 | else => sep_posix, |
| | 20 | }; |
| 18 | | 21 | |
| 19 | pub const sep_str_windows_uefi = "\\"; | 22 | pub const sep_str_windows = "\\"; |
| 20 | pub const sep_str_posix = "/"; | 23 | pub const sep_str_posix = "/"; |
| 21 | pub const sep_str = if (native_os == .windows or native_os == .uefi) sep_str_windows_uefi else sep_str_posix; | 24 | pub const sep_str = switch (native_os) { |
| | 25 | .windows, .uefi => sep_str_windows, |
| | 26 | else => sep_str_posix, |
| | 27 | }; |
| 22 | | 28 | |
| 23 | pub const delimiter_windows = ';'; | 29 | pub const delimiter_windows = ';'; |
| 24 | pub const delimiter_posix = ':'; | 30 | pub const delimiter_posix = ':'; |
| ... | @@ -116,7 +122,7 @@ fn testJoinMaybeZUefi(paths: []const []const u8, expected: []const u8, zero: boo | ... | @@ -116,7 +122,7 @@ fn testJoinMaybeZUefi(paths: []const []const u8, expected: []const u8, zero: boo |
| 116 | return byte == '\\'; | 122 | return byte == '\\'; |
| 117 | } | 123 | } |
| 118 | }.isSep; | 124 | }.isSep; |
| 119 | const actual = try joinSepMaybeZ(testing.allocator, sep_windows_uefi, uefiIsSep, paths, zero); | 125 | const actual = try joinSepMaybeZ(testing.allocator, sep_windows, uefiIsSep, paths, zero); |
| 120 | defer testing.allocator.free(actual); | 126 | defer testing.allocator.free(actual); |
| 121 | try testing.expectEqualSlices(u8, expected, if (zero) actual[0 .. actual.len - 1 :0] else actual); | 127 | try testing.expectEqualSlices(u8, expected, if (zero) actual[0 .. actual.len - 1 :0] else actual); |
| 122 | } | 128 | } |
| ... | @@ -127,7 +133,7 @@ fn testJoinMaybeZWindows(paths: []const []const u8, expected: []const u8, zero: | ... | @@ -127,7 +133,7 @@ fn testJoinMaybeZWindows(paths: []const []const u8, expected: []const u8, zero: |
| 127 | return byte == '/' or byte == '\\'; | 133 | return byte == '/' or byte == '\\'; |
| 128 | } | 134 | } |
| 129 | }.isSep; | 135 | }.isSep; |
| 130 | const actual = try joinSepMaybeZ(testing.allocator, sep_windows_uefi, windowsIsSep, paths, zero); | 136 | const actual = try joinSepMaybeZ(testing.allocator, sep_windows, windowsIsSep, paths, zero); |
| 131 | defer testing.allocator.free(actual); | 137 | defer testing.allocator.free(actual); |
| 132 | try testing.expectEqualSlices(u8, expected, if (zero) actual[0 .. actual.len - 1 :0] else actual); | 138 | try testing.expectEqualSlices(u8, expected, if (zero) actual[0 .. actual.len - 1 :0] else actual); |
| 133 | } | 139 | } |
| ... | @@ -604,7 +610,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 { | ... | @@ -604,7 +610,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 { |
| 604 | result[0] = asciiUpper(result[0]); | 610 | result[0] = asciiUpper(result[0]); |
| 605 | // Remove the trailing slash if present, eg. if the cwd is a root | 611 | // Remove the trailing slash if present, eg. if the cwd is a root |
| 606 | // directory. | 612 | // directory. |
| 607 | if (cwd.len > 0 and cwd[cwd.len - 1] == sep_windows_uefi) { | 613 | if (cwd.len > 0 and cwd[cwd.len - 1] == sep_windows) { |
| 608 | result_index -= 1; | 614 | result_index -= 1; |
| 609 | } | 615 | } |
| 610 | } | 616 | } |
| ... | @@ -641,7 +647,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 { | ... | @@ -641,7 +647,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 { |
| 641 | break; | 647 | break; |
| 642 | } | 648 | } |
| 643 | } else { | 649 | } else { |
| 644 | result[result_index] = sep_windows_uefi; | 650 | result[result_index] = sep_windows; |
| 645 | result_index += 1; | 651 | result_index += 1; |
| 646 | mem.copy(u8, result[result_index..], component); | 652 | mem.copy(u8, result[result_index..], component); |
| 647 | result_index += component.len; | 653 | result_index += component.len; |