Skip to content

Dir.makePath handles .. in the sub_path differently per-platform #18452

@squeek502

Description

@squeek502

Zig Version

0.12.0-dev.2018+9a56228c2

Steps to Reproduce and Observed Behavior

From a test in #17499 (cc @rootbeer):

test "makepath relative walks" {
    if (builtin.os.tag == .wasi) return error.SkipZigTest;

    var tmp = tmpDir(.{});
    defer tmp.cleanup();

    const relPath = try fs.path.join(testing.allocator, &.{
        "first", "..", "second", "..", "third", "..", "first", "A", "..", "B", "..", "C",
    });
    defer testing.allocator.free(relPath);

    try tmp.dir.makePath(relPath);

    // verify created directories exist:
    try expectDir(tmp.dir, "first" ++ fs.path.sep_str ++ "A");
    try expectDir(tmp.dir, "first" ++ fs.path.sep_str ++ "B");
    try expectDir(tmp.dir, "first" ++ fs.path.sep_str ++ "C");
    try expectDir(tmp.dir, "second");
    try expectDir(tmp.dir, "third");
}

Expected Behavior

All platforms to have similar behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.docsos-linuxLinuxos-windowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions