| author | |
| committer | |
| log | a7dfc6470f0cb73c53f11590cf89d6348a81030e |
| tree | e5507b90658e5e6289456018e2b3d76e804c6ccb |
| parent | 2886a8bf45d3e340282c7f0dc8b35455e935f0b2 |
3 files changed, 10 insertions(+), 15 deletions(-)
lib/std/fs.zig+2-3| ... | @@ -642,10 +642,9 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { | ... | @@ -642,10 +642,9 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 642 | // If ImagePathName is a symlink, then it will contain the path of the | 642 | // If ImagePathName is a symlink, then it will contain the path of the |
| 643 | // symlink, not the path that the symlink points to. We want the path | 643 | // symlink, not the path that the symlink points to. We want the path |
| 644 | // that the symlink points to, though, so we need to get the realpath. | 644 | // that the symlink points to, though, so we need to get the realpath. |
| 645 | const pathname_w = try windows.wToPrefixedFileW(null, image_path_name); | 645 | var pathname_w = try windows.wToPrefixedFileW(null, image_path_name); |
| 646 | 646 | ||
| 647 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; | 647 | const wide_slice = std.fs.cwd().realpathW(pathname_w.span(), &pathname_w.data) catch |err| switch (err) { |
| 648 | const wide_slice = std.fs.cwd().realpathW(pathname_w.span(), &wide_buf) catch |err| switch (err) { | ||
| 649 | error.InvalidWtf8 => unreachable, | 648 | error.InvalidWtf8 => unreachable, |
| 650 | else => |e| return e, | 649 | else => |e| return e, |
| 651 | }; | 650 | }; |
lib/std/fs/Dir.zig+4-6| ... | @@ -1369,10 +1369,9 @@ pub fn realpath(self: Dir, pathname: []const u8, out_buffer: []u8) RealPathError | ... | @@ -1369,10 +1369,9 @@ pub fn realpath(self: Dir, pathname: []const u8, out_buffer: []u8) RealPathError |
| 1369 | @compileError("realpath is not available on WASI"); | 1369 | @compileError("realpath is not available on WASI"); |
| 1370 | } | 1370 | } |
| 1371 | if (native_os == .windows) { | 1371 | if (native_os == .windows) { |
| 1372 | const pathname_w = try windows.sliceToPrefixedFileW(self.fd, pathname); | 1372 | var pathname_w = try windows.sliceToPrefixedFileW(self.fd, pathname); |
| 1373 | 1373 | ||
| 1374 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; | 1374 | const wide_slice = try self.realpathW(pathname_w.span(), &pathname_w.data); |
| 1375 | const wide_slice = try self.realpathW(pathname_w.span(), &wide_buf); | ||
| 1376 | 1375 | ||
| 1377 | const len = std.unicode.calcWtf8Len(wide_slice); | 1376 | const len = std.unicode.calcWtf8Len(wide_slice); |
| 1378 | if (len > out_buffer.len) | 1377 | if (len > out_buffer.len) |
| ... | @@ -1389,10 +1388,9 @@ pub fn realpath(self: Dir, pathname: []const u8, out_buffer: []u8) RealPathError | ... | @@ -1389,10 +1388,9 @@ pub fn realpath(self: Dir, pathname: []const u8, out_buffer: []u8) RealPathError |
| 1389 | /// See also `Dir.realpath`, `realpathZ`. | 1388 | /// See also `Dir.realpath`, `realpathZ`. |
| 1390 | pub fn realpathZ(self: Dir, pathname: [*:0]const u8, out_buffer: []u8) RealPathError![]u8 { | 1389 | pub fn realpathZ(self: Dir, pathname: [*:0]const u8, out_buffer: []u8) RealPathError![]u8 { |
| 1391 | if (native_os == .windows) { | 1390 | if (native_os == .windows) { |
| 1392 | const pathname_w = try windows.cStrToPrefixedFileW(self.fd, pathname); | 1391 | var pathname_w = try windows.cStrToPrefixedFileW(self.fd, pathname); |
| 1393 | 1392 | ||
| 1394 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; | 1393 | const wide_slice = try self.realpathW(pathname_w.span(), &pathname_w.data); |
| 1395 | const wide_slice = try self.realpathW(pathname_w.span(), &wide_buf); | ||
| 1396 | 1394 | ||
| 1397 | const len = std.unicode.calcWtf8Len(wide_slice); | 1395 | const len = std.unicode.calcWtf8Len(wide_slice); |
| 1398 | if (len > out_buffer.len) | 1396 | if (len > out_buffer.len) |
lib/std/posix.zig+4-6| ... | @@ -5675,10 +5675,9 @@ pub const RealPathError = error{ | ... | @@ -5675,10 +5675,9 @@ pub const RealPathError = error{ |
| 5675 | /// Calling this function is usually a bug. | 5675 | /// Calling this function is usually a bug. |
| 5676 | pub fn realpath(pathname: []const u8, out_buffer: *[max_path_bytes]u8) RealPathError![]u8 { | 5676 | pub fn realpath(pathname: []const u8, out_buffer: *[max_path_bytes]u8) RealPathError![]u8 { |
| 5677 | if (native_os == .windows) { | 5677 | if (native_os == .windows) { |
| 5678 | const pathname_w = try windows.sliceToPrefixedFileW(null, pathname); | 5678 | var pathname_w = try windows.sliceToPrefixedFileW(null, pathname); |
| 5679 | 5679 | ||
| 5680 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; | 5680 | const wide_slice = try realpathW(pathname_w.span(), &pathname_w.data); |
| 5681 | const wide_slice = try realpathW(pathname_w.span(), &wide_buf); | ||
| 5682 | 5681 | ||
| 5683 | const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice); | 5682 | const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice); |
| 5684 | return out_buffer[0..end_index]; | 5683 | return out_buffer[0..end_index]; |
| ... | @@ -5694,10 +5693,9 @@ pub fn realpath(pathname: []const u8, out_buffer: *[max_path_bytes]u8) RealPathE | ... | @@ -5694,10 +5693,9 @@ pub fn realpath(pathname: []const u8, out_buffer: *[max_path_bytes]u8) RealPathE |
| 5694 | /// Calling this function is usually a bug. | 5693 | /// Calling this function is usually a bug. |
| 5695 | pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[max_path_bytes]u8) RealPathError![]u8 { | 5694 | pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[max_path_bytes]u8) RealPathError![]u8 { |
| 5696 | if (native_os == .windows) { | 5695 | if (native_os == .windows) { |
| 5697 | const pathname_w = try windows.cStrToPrefixedFileW(null, pathname); | 5696 | var pathname_w = try windows.cStrToPrefixedFileW(null, pathname); |
| 5698 | 5697 | ||
| 5699 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; | 5698 | const wide_slice = try realpathW(pathname_w.span(), &pathname_w.data); |
| 5700 | const wide_slice = try realpathW(pathname_w.span(), &wide_buf); | ||
| 5701 | 5699 | ||
| 5702 | const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice); | 5700 | const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice); |
| 5703 | return out_buffer[0..end_index]; | 5701 | return out_buffer[0..end_index]; |