Skip to content

Windows: std.fs.Dir.deleteDir() will delete files #5536

Closed

Description

@squeek502

Test code:

const std = @import("std");

pub fn main() !void {
    if (std.fs.cwd().createFile("file.txt", .{})) |file| {
        file.close();
    } else |err| switch (err) {
        error.PathAlreadyExists => {},
        else => return err,
    }
    // this should fail, but instead it succeeds and deletes file.txt
    return std.fs.cwd().deleteDir("file.txt");
}

I expect the above to return error.NotDir, but instead it just deletes the file.

Even more minimal example has the same behaviour, assuming file.txt already exists:

const std = @import("std");

pub fn main() !void {
    // this should fail, but instead it succeeds and deletes file.txt
    return std.fs.cwd().deleteDir("file.txt");
}

Activity

  1. added a commit that references this issue on Jun 4, 2020
    b2982c2
  2. added a commit that references this issue on Jun 5, 2020
    f7b6957
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions