| ... | @@ -1349,13 +1349,11 @@ pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) RealPathErr | ... | @@ -1349,13 +1349,11 @@ pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) RealPathErr |
| 1349 | | 1349 | |
| 1350 | var wide_buf: [w.PATH_MAX_WIDE]u16 = undefined; | 1350 | var wide_buf: [w.PATH_MAX_WIDE]u16 = undefined; |
| 1351 | const wide_slice = try w.GetFinalPathNameByHandle(h_file, .{}, &wide_buf); | 1351 | const wide_slice = try w.GetFinalPathNameByHandle(h_file, .{}, &wide_buf); |
| 1352 | var big_out_buf: [fs.max_path_bytes]u8 = undefined; | 1352 | const len = std.unicode.calcWtf8Len(wide_slice); |
| 1353 | const end_index = std.unicode.wtf16LeToWtf8(&big_out_buf, wide_slice); | 1353 | if (len > out_buffer.len) |
| 1354 | if (end_index > out_buffer.len) | | |
| 1355 | return error.NameTooLong; | 1354 | return error.NameTooLong; |
| 1356 | const result = out_buffer[0..end_index]; | 1355 | const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice); |
| 1357 | @memcpy(result, big_out_buf[0..end_index]); | 1356 | return out_buffer[0..end_index]; |
| 1358 | return result; | | |
| 1359 | } | 1357 | } |
| 1360 | | 1358 | |
| 1361 | pub const RealPathAllocError = RealPathError || Allocator.Error; | 1359 | pub const RealPathAllocError = RealPathError || Allocator.Error; |