@@ -2491,15 +2491,15 @@ pub fn getWin32PathType(comptime T: type, path: []const T) Win32PathType {
24912491 if (path .len < 1 ) return .relative ;
24922492
24932493 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 ])) {
24952495 // \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 ;
24972497 // \\. 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 , '?' ) )) {
24992499 // exactly \\. or \\? with nothing trailing
25002500 if (path .len == 3 ) return .root_local_device ;
25012501 // \\.\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 ;
25032503 }
25042504 // \\x
25052505 return .unc_absolute ;
@@ -2538,9 +2538,9 @@ pub fn getWin32PathType(comptime T: type, path: []const T) Win32PathType {
25382538 else = > @compileError ("unsupported type: " ++ @typeName (T )),
25392539 };
25402540 // 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 ;
25422542 // 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 ;
25442544 // x:
25452545 return .drive_relative ;
25462546 }
@@ -2632,12 +2632,13 @@ fn getLocalDevicePathType(comptime T: type, path: []const T) LocalDevicePathType
26322632 std .debug .assert (getWin32PathType (T , path ) == .local_device );
26332633 }
26342634
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 ,
26412642 else = > unreachable ,
26422643 };
26432644}
@@ -2664,7 +2665,7 @@ pub fn ntToWin32Namespace(path: []const u16, out: []u16) error{ NameTooLong, Not
26642665 // `\??\UNC\` should be replaced by `\\` (two backslashes)
26652666 const is_unc = after_prefix .len >= 4 and
26662667 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 ]);
26682669 const win32_len = path .len - @as (usize , if (is_unc ) 6 else 4 );
26692670 if (out .len < win32_len ) return error .NameTooLong ;
26702671 if (is_unc ) {
0 commit comments