Skip to content

Parent directory (..) does not work on windows #16779

@matklad

Description

@matklad

Zig Version

0.10.1

Steps to Reproduce and Observed Behavior

pub fn main() !void {
    var current = try std.fs.cwd().openDir(".", .{}); // dup cwd so that the caller can close
    errdefer current.close();

    var level: u32 = 0;
    while (level < 16) : (level += 1) {
        std.debug.print("{s}\n", .{try current.realpathAlloc(std.heap.page_allocator, ".")});
        var parent = try current.openDir("..", .{});
        current.close();
        current = parent;
    }
}
PS C:\Users\matklad\p\tigerbeetle> .\zig\zig.exe run src/shell.zig
C:\Users\matklad\p\tigerbeetle
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p
C:\Users\matklad\p

Expected Behavior

Go up! :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-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