authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-08-11 14:36:24-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-08-15 15:52:34-07:00
log3819e69376ae18289ef9a7422c3644bc8ab288e0
treedb08a326c8ed7044d2c0deb76ad353b7075eec2f
parent19b219bc8adbfeb1d1a9faa691563a8e3ff390b8

windows.GetFinalPathNameByHandle: Support UNC paths


1 files changed, 10 insertions(+), 0 deletions(-)

lib/std/os/windows.zig+10
......@@ -1226,8 +1226,18 @@ pub fn GetFinalPathNameByHandle(
12261226
12271227 const file_path_begin_index = mem.indexOfPos(u16, final_path, expected_prefix.len, &[_]u16{'\\'}) orelse unreachable;
12281228 const volume_name_u16 = final_path[0..file_path_begin_index];
1229 const device_name_u16 = volume_name_u16[expected_prefix.len..];
12291230 const file_name_u16 = final_path[file_path_begin_index..];
12301231
1232 // MUP is Multiple UNC Provider, and indicates that the path is a UNC
1233 // path. In this case, the canonical UNC path can be gotten by just
1234 // dropping the \Device\Mup\ and making sure the path begins with \\
1235 if (mem.eql(u16, device_name_u16, std.unicode.utf8ToUtf16LeStringLiteral("Mup"))) {
1236 out_buffer[0] = '\\';
1237 mem.copyForwards(u16, out_buffer[1..][0..file_name_u16.len], file_name_u16);
1238 return out_buffer[0 .. 1 + file_name_u16.len];
1239 }
1240
12311241 // Get DOS volume name. DOS volume names are actually symbolic link objects to the
12321242 // actual NT volume. For example:
12331243 // (NT) \Device\HarddiskVolume4 => (DOS) \DosDevices\C: == (DOS) C: