authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-11 11:00:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-11 11:00:19-07:00
log3d89ff51300454467a39427b938110afe2d1039c
tree5487ca931cda98e814fd8b01cbfd89f4c276c024
parentb65a88416974e697f1cf2402ca7550f6225f8d39

std.fs.path: revert recent public API change

41fd343508880ffdfbc83c7b053237da09199f02 made a breaking change to the public API; this commit reverts the API changes but keeps the improved logic.

2 files changed, 15 insertions(+), 9 deletions(-)

lib/std/fs/path.zig+14-8
......@@ -12,13 +12,19 @@ const fs = std.fs;
1212const process = std.process;
1313const native_os = builtin.target.os.tag;
1414
15pub const sep_windows_uefi = '\\';
15pub const sep_windows = '\\';
1616pub const sep_posix = '/';
17pub const sep = if (native_os == .windows or native_os == .uefi) sep_windows_uefi else sep_posix;
17pub const sep = switch (native_os) {
18 .windows, .uefi => sep_windows,
19 else => sep_posix,
20};
1821
19pub const sep_str_windows_uefi = "\\";
22pub const sep_str_windows = "\\";
2023pub const sep_str_posix = "/";
21pub const sep_str = if (native_os == .windows or native_os == .uefi) sep_str_windows_uefi else sep_str_posix;
24pub const sep_str = switch (native_os) {
25 .windows, .uefi => sep_str_windows,
26 else => sep_str_posix,
27};
2228
2329pub const delimiter_windows = ';';
2430pub const delimiter_posix = ':';
......@@ -116,7 +122,7 @@ fn testJoinMaybeZUefi(paths: []const []const u8, expected: []const u8, zero: boo
116122 return byte == '\\';
117123 }
118124 }.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);
120126 defer testing.allocator.free(actual);
121127 try testing.expectEqualSlices(u8, expected, if (zero) actual[0 .. actual.len - 1 :0] else actual);
122128}
......@@ -127,7 +133,7 @@ fn testJoinMaybeZWindows(paths: []const []const u8, expected: []const u8, zero:
127133 return byte == '/' or byte == '\\';
128134 }
129135 }.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);
131137 defer testing.allocator.free(actual);
132138 try testing.expectEqualSlices(u8, expected, if (zero) actual[0 .. actual.len - 1 :0] else actual);
133139}
......@@ -604,7 +610,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 {
604610 result[0] = asciiUpper(result[0]);
605611 // Remove the trailing slash if present, eg. if the cwd is a root
606612 // 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) {
608614 result_index -= 1;
609615 }
610616 }
......@@ -641,7 +647,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 {
641647 break;
642648 }
643649 } else {
644 result[result_index] = sep_windows_uefi;
650 result[result_index] = sep_windows;
645651 result_index += 1;
646652 mem.copy(u8, result[result_index..], component);
647653 result_index += component.len;
lib/std/os/uefi.zig+1-1
......@@ -8,7 +8,7 @@ pub const Status = @import("uefi/status.zig").Status;
88pub const tables = @import("uefi/tables.zig");
99
1010/// The memory type to allocate when using the pool
11/// Defaults to .LoaderData, the default data allocation type
11/// Defaults to .LoaderData, the default data allocation type
1212/// used by UEFI applications to allocate pool memory.
1313pub var efi_pool_memory_type: tables.MemoryType = .LoaderData;
1414pub const pool_allocator = @import("uefi/pool_allocator.zig").pool_allocator;