-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix for Windows: std.os.windows.DeleteFile() #6397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Nice. Here's a possible test case that can be added to test "deleteDir" {
var tmp_dir = tmpDir(.{});
defer tmp_dir.cleanup();
// deleting a non-existent directory
testing.expectError(error.FileNotFound, tmp_dir.dir.deleteDir("test_dir"));
var dir = try tmp_dir.dir.makeOpenPath("test_dir", .{});
var file = try dir.createFile("test_file", .{});
file.close();
dir.close();
// deleting a non-empty directory
testing.expectError(error.DirNotEmpty, tmp_dir.dir.deleteDir("test_dir"));
dir = try tmp_dir.dir.openDir("test_dir", .{});
try dir.deleteFile("test_file");
dir.close();
// deleting an empty directory
try tmp_dir.dir.deleteDir("test_dir");
} |
We definitely need a test case added for this, thanks for suggesting this @squeek502! |
@suirad, have you perhaps experimented with ReactOS approach where instead of setting |
I've updated the code adding @squeek502 's test and moving the non empty directory detection into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just one more nitpick which doesn't tweak the behaviour of this PR, and we're good to go.
a proper error when attempting to delete a directory that isnt empty
Re-adds the test that was added and then reverted in ziglang#6397, but with the test for ziglang#5537 skipped for now since that issue is no longer fixed.
This commit addresses #5537 using the following test:
I considered adding this test to the std to catch regressions but I wasn't sure if it was wanted to be added and I also wasn't sure exactly where in the repo to add it.