zig icon indicating copy to clipboard operation
zig copied to clipboard

fix compilation errors for fs and fs.Dir

Open JustinBraben opened this issue 1 year ago • 4 comments

Fixes the std.fs related compiler errors mentioned in #20505

JustinBraben avatar Oct 09 '24 19:10 JustinBraben

Ok! I can rework it.

JustinBraben avatar Oct 10 '24 17:10 JustinBraben

Worth mentioning I got the original mem.sliceTo(path_w, 0) from the function isAbsoluteWindowsW , which is asserted before most of these W calls.

pub fn isAbsoluteWindowsW(path_w: [*:0]const u16) bool {
    return isAbsoluteWindowsImpl(u16, mem.sliceTo(path_w, 0));
}

Should that be changed to:

pub fn isAbsoluteWindowsW(path_w: [*:0]const u16) bool {
    return isAbsoluteWindowsImpl(u16, mem.span(path_w));
}

Ok if that is outside the scope for this PR though

JustinBraben avatar Oct 10 '24 17:10 JustinBraben

Ok landed on this

pub fn symLinkAbsoluteW(
    target_path_w: [*:0]const u16,
    sym_link_path_w: [*:0]const u16,
    flags: Dir.SymLinkFlags,
) !void {
    assert(path.isAbsoluteWindowsW(target_path_w));
    assert(path.isAbsoluteWindowsW(sym_link_path_w));
    return windows.CreateSymbolicLink(null, mem.span(sym_link_path_w), mem.span(target_path_w), flags.is_directory);
}

JustinBraben avatar Oct 11 '24 23:10 JustinBraben

@linusg I switched the sliceTo to mem.span . Think it's ready for another look.

JustinBraben avatar Oct 12 '24 01:10 JustinBraben