| author | |
| committer | |
| log | abd389209b2b25ac3d3567797bff580c2ce7d9ad |
| tree | 68400346b0bbd5fb3b124742fab41c6b7dd788b8 |
| parent | e1e536e03d28942fe6dfa4a9f3881af3fb57a458 |
3 files changed, 19 insertions(+), 7 deletions(-)
doc/docgen.zig+1-1| ... | @@ -55,7 +55,7 @@ pub fn main() !void { | ... | @@ -55,7 +55,7 @@ pub fn main() !void { |
| 55 | // TODO issue #709 | 55 | // TODO issue #709 |
| 56 | // disabled to pass CI tests, but obviously we want to implement this | 56 | // disabled to pass CI tests, but obviously we want to implement this |
| 57 | // and then remove this workaround | 57 | // and then remove this workaround |
| 58 | if (builtin.os == builtin.Os.linux) { | 58 | if (builtin.os != builtin.Os.windows) { |
| 59 | os.deleteTree(allocator, tmp_dir_name) catch {}; | 59 | os.deleteTree(allocator, tmp_dir_name) catch {}; |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
std/os/index.zig+8-3| ... | @@ -1050,14 +1050,14 @@ const DeleteTreeError = error { | ... | @@ -1050,14 +1050,14 @@ const DeleteTreeError = error { |
| 1050 | }; | 1050 | }; |
| 1051 | pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!void { | 1051 | pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!void { |
| 1052 | start_over: while (true) { | 1052 | start_over: while (true) { |
| 1053 | var got_access_denied = false; | ||
| 1053 | // First, try deleting the item as a file. This way we don't follow sym links. | 1054 | // First, try deleting the item as a file. This way we don't follow sym links. |
| 1054 | if (deleteFile(allocator, full_path)) { | 1055 | if (deleteFile(allocator, full_path)) { |
| 1055 | return; | 1056 | return; |
| 1056 | } else |err| switch (err) { | 1057 | } else |err| switch (err) { |
| 1057 | error.FileNotFound => return, | 1058 | error.FileNotFound => return, |
| 1058 | |||
| 1059 | error.AccessDenied, | ||
| 1060 | error.IsDir => {}, | 1059 | error.IsDir => {}, |
| 1060 | error.AccessDenied => got_access_denied = true, | ||
| 1061 | 1061 | ||
| 1062 | error.OutOfMemory, | 1062 | error.OutOfMemory, |
| 1063 | error.SymLinkLoop, | 1063 | error.SymLinkLoop, |
| ... | @@ -1072,7 +1072,12 @@ pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError! | ... | @@ -1072,7 +1072,12 @@ pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError! |
| 1072 | } | 1072 | } |
| 1073 | { | 1073 | { |
| 1074 | var dir = Dir.open(allocator, full_path) catch |err| switch (err) { | 1074 | var dir = Dir.open(allocator, full_path) catch |err| switch (err) { |
| 1075 | error.NotDir => continue :start_over, | 1075 | error.NotDir => { |
| 1076 | if (got_access_denied) { | ||
| 1077 | return error.AccessDenied; | ||
| 1078 | } | ||
| 1079 | continue :start_over; | ||
| 1080 | }, | ||
| 1076 | 1081 | ||
| 1077 | error.OutOfMemory, | 1082 | error.OutOfMemory, |
| 1078 | error.AccessDenied, | 1083 | error.AccessDenied, |
std/os/test.zig+10-3| ... | @@ -1,18 +1,25 @@ | ... | @@ -1,18 +1,25 @@ |
| 1 | const std = @import("../index.zig"); | 1 | const std = @import("../index.zig"); |
| 2 | const os = std.os; | 2 | const os = std.os; |
| 3 | const debug = std.debug; | 3 | const assert = std.debug.assert; |
| 4 | const io = std.io; | 4 | const io = std.io; |
| 5 | 5 | ||
| 6 | const a = std.debug.global_allocator; | 6 | const a = std.debug.global_allocator; |
| 7 | 7 | ||
| 8 | const builtin = @import("builtin"); | ||
| 9 | |||
| 8 | test "makePath, put some files in it, deleteTree" { | 10 | test "makePath, put some files in it, deleteTree" { |
| 11 | if (builtin.os == builtin.Os.windows) { | ||
| 12 | // TODO implement os.Dir for windows | ||
| 13 | // https://github.com/zig-lang/zig/issues/709 | ||
| 14 | return; | ||
| 15 | } | ||
| 9 | try os.makePath(a, "os_test_tmp/b/c"); | 16 | try os.makePath(a, "os_test_tmp/b/c"); |
| 10 | try io.writeFile(a, "os_test_tmp/b/c/file.txt", "nonsense"); | 17 | try io.writeFile(a, "os_test_tmp/b/c/file.txt", "nonsense"); |
| 11 | try io.writeFile(a, "os_test_tmp/b/file2.txt", "blah"); | 18 | try io.writeFile(a, "os_test_tmp/b/file2.txt", "blah"); |
| 12 | try os.deleteTree(a, "os_test_tmp"); | 19 | try os.deleteTree(a, "os_test_tmp"); |
| 13 | if (os.Dir.open(a, "os_test_tmp")) |dir| { | 20 | if (os.Dir.open(a, "os_test_tmp")) |dir| { |
| 14 | debug.assert(false); // this should not happen! | 21 | @panic("expected error"); |
| 15 | } else |err| { | 22 | } else |err| { |
| 16 | debug.assert(err == error.PathNotFound); | 23 | assert(err == error.PathNotFound); |
| 17 | } | 24 | } |
| 18 | } | 25 | } |