mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
we are now long paths
This commit is contained in:
@@ -2041,7 +2041,7 @@ pub fn toWDirPath(wbuf: []u16, utf8: []const u8) [:0]const u16 {
|
||||
return toWPathMaybeDir(wbuf, utf8, true);
|
||||
}
|
||||
|
||||
pub fn toKernel32Path(wbuf: []u16, utf8: []const u8) [:0]const u16 {
|
||||
pub fn toKernel32Path(wbuf: []u16, utf8: []const u8) [:0]u16 {
|
||||
const path = if (hasPrefixComptime(utf8, bun.windows.nt_object_prefix_u8))
|
||||
utf8[bun.windows.nt_object_prefix_u8.len..]
|
||||
else
|
||||
@@ -2088,6 +2088,15 @@ pub fn toWPathMaybeDir(wbuf: []u16, utf8: []const u8, comptime add_trailing_lash
|
||||
wbuf[0..wbuf.len -| (1 + @as(usize, @intFromBool(add_trailing_lash)))],
|
||||
);
|
||||
|
||||
// Many Windows APIs expect normalized path slashes, particularly when the
|
||||
// long path prefix is added or the nt object prefix. To make this easier,
|
||||
// but a little redundant, this function always normalizes the slashes here.
|
||||
//
|
||||
// An example of this is GetFileAttributesW(L"C:\\hello/world.txt") being OK
|
||||
// but GetFileAttributesW(L"\\\\?\\C:\\hello/world.txt") is NOT
|
||||
if (Environment.isWindows)
|
||||
bun.path.dangerouslyConvertPathToWindowsInPlace(u16, wbuf[0..result.count]);
|
||||
|
||||
if (add_trailing_lash and result.count > 0 and wbuf[result.count - 1] != '\\') {
|
||||
wbuf[result.count] = '\\';
|
||||
result.count += 1;
|
||||
|
||||
Reference in New Issue
Block a user