| ... | ... | @@ -2491,15 +2491,15 @@ pub fn getWin32PathType(comptime T: type, path: []const T) Win32PathType { |
| 2491 | 2491 | if (path.len < 1) return .relative; |
| 2492 | 2492 | |
| 2493 | 2493 | const windows_path = std.fs.path.PathType.windows; |
| 2494 | | if (windows_path.isSep(T, mem.littleToNative(T, path[0]))) { |
| 2494 | if (windows_path.isSep(T, path[0])) { |
| 2495 | 2495 | // \x |
| 2496 | | if (path.len < 2 or !windows_path.isSep(T, mem.littleToNative(T, path[1]))) return .rooted; |
| 2496 | if (path.len < 2 or !windows_path.isSep(T, path[1])) return .rooted; |
| 2497 | 2497 | // \\. or \\? |
| 2498 | | if (path.len > 2 and (mem.littleToNative(T, path[2]) == '.' or mem.littleToNative(T, path[2]) == '?')) { |
| 2498 | if (path.len > 2 and (path[2] == mem.nativeToLittle(T, '.') or path[2] == mem.nativeToLittle(T, '?'))) { |
| 2499 | 2499 | // exactly \\. or \\? with nothing trailing |
| 2500 | 2500 | if (path.len == 3) return .root_local_device; |
| 2501 | 2501 | // \\.\x or \\?\x |
| 2502 | | if (windows_path.isSep(T, mem.littleToNative(T, path[3]))) return .local_device; |
| 2502 | if (windows_path.isSep(T, path[3])) return .local_device; |
| 2503 | 2503 | } |
| 2504 | 2504 | // \\x |
| 2505 | 2505 | return .unc_absolute; |
| ... | ... | @@ -2538,9 +2538,9 @@ pub fn getWin32PathType(comptime T: type, path: []const T) Win32PathType { |
| 2538 | 2538 | else => @compileError("unsupported type: " ++ @typeName(T)), |
| 2539 | 2539 | }; |
| 2540 | 2540 | // x |
| 2541 | | if (path.len < colon_i + 1 or mem.littleToNative(T, path[colon_i]) != ':') return .relative; |
| 2541 | if (path.len < colon_i + 1 or path[colon_i] != mem.nativeToLittle(T, ':')) return .relative; |
| 2542 | 2542 | // x:\ |
| 2543 | | if (path.len > colon_i + 1 and windows_path.isSep(T, mem.littleToNative(T, path[colon_i + 1]))) return .drive_absolute; |
| 2543 | if (path.len > colon_i + 1 and windows_path.isSep(T, path[colon_i + 1])) return .drive_absolute; |
| 2544 | 2544 | // x: |
| 2545 | 2545 | return .drive_relative; |
| 2546 | 2546 | } |
| ... | ... | @@ -2632,12 +2632,13 @@ fn getLocalDevicePathType(comptime T: type, path: []const T) LocalDevicePathType |
| 2632 | 2632 | std.debug.assert(getWin32PathType(T, path) == .local_device); |
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | | const all_backslash = mem.littleToNative(T, path[0]) == '\\' and |
| 2636 | | mem.littleToNative(T, path[1]) == '\\' and |
| 2637 | | mem.littleToNative(T, path[3]) == '\\'; |
| 2638 | | return switch (mem.littleToNative(T, path[2])) { |
| 2639 | | '?' => if (all_backslash) .verbatim else .fake_verbatim, |
| 2640 | | '.' => .local_device, |
| 2635 | const backslash = mem.nativeToLittle(T, '\\'); |
| 2636 | const all_backslash = path[0] == backslash and |
| 2637 | path[1] == backslash and |
| 2638 | path[3] == backslash; |
| 2639 | return switch (path[2]) { |
| 2640 | mem.nativeToLittle(T, '?') => if (all_backslash) .verbatim else .fake_verbatim, |
| 2641 | mem.nativeToLittle(T, '.') => .local_device, |
| 2641 | 2642 | else => unreachable, |
| 2642 | 2643 | }; |
| 2643 | 2644 | } |
| ... | ... | @@ -2664,7 +2665,7 @@ pub fn ntToWin32Namespace(path: []const u16, out: []u16) error{ NameTooLong, Not |
| 2664 | 2665 | // `\??\UNC\` should be replaced by `\\` (two backslashes) |
| 2665 | 2666 | const is_unc = after_prefix.len >= 4 and |
| 2666 | 2667 | eqlIgnoreCaseWtf16(after_prefix[0..3], std.unicode.utf8ToUtf16LeStringLiteral("UNC")) and |
| 2667 | | std.fs.path.PathType.windows.isSep(u16, std.mem.littleToNative(u16, after_prefix[3])); |
| 2668 | std.fs.path.PathType.windows.isSep(u16, after_prefix[3]); |
| 2668 | 2669 | const win32_len = path.len - @as(usize, if (is_unc) 6 else 4); |
| 2669 | 2670 | if (out.len < win32_len) return error.NameTooLong; |
| 2670 | 2671 | if (is_unc) { |