authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-08-10 20:44:22+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-08-10 20:44:22+02:00
log901bf0a2e2821caa1087b03ed308700ec9135c87
treee9373681322a19ca88ae245b96c98e7dd26fdce2
parent73b9f657460b040eaed4145a88f76db997d73987

Convert prefix from u8 to u16 programmatically


1 files changed, 4 insertions(+), 1 deletions(-)

lib/std/os/windows.zig+4-1
......@@ -1002,7 +1002,10 @@ pub fn GetFinalPathNameByHandle(
10021002
10031003 // Look for `\DosDevices\` prefix. We don't really care if there are more than one symlinks
10041004 // with traditional DOS drive letters, so pick the first one available.
1005 const prefix = &[_]u16{ '\\', 'D', 'o', 's', 'D', 'e', 'v', 'i', 'c', 'e', 's', '\\' };
1005 const prefix_u8 = "\\DosDevices\\";
1006 var prefix_buf_u16: [prefix_u8.len]u16 = undefined;
1007 const prefix_len_u16 = std.unicode.utf8ToUtf16Le(prefix_buf_u16[0..], prefix_u8[0..]) catch unreachable;
1008 const prefix = prefix_buf_u16[0..prefix_len_u16];
10061009
10071010 if (std.mem.startsWith(u16, symlink, prefix)) {
10081011 const drive_letter = symlink[prefix.len..];