Skip to content

Commit 901bf0a

Browse files
committed
Convert prefix from u8 to u16 programmatically
1 parent 73b9f65 commit 901bf0a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/std/os/windows.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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..];

0 commit comments

Comments
 (0)