Skip to content

Commit

Permalink
fix: std.fs.accessAbsolute with .read_write outputs stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Feb 4, 2025
1 parent 2a2ff67 commit 3cbc42a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/buzz_fs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ pub export fn exists(ctx: *api.NativeCtx) callconv(.c) c_int {
var accessed = true;

if (std.fs.path.isAbsolute(filename_slice)) {
std.fs.accessAbsolute(filename_slice, .{ .mode = .read_write }) catch {
std.fs.accessAbsolute(filename_slice, .{ .mode = .read_only }) catch {
accessed = false;
};
} else {
std.fs.cwd().access(filename_slice, .{ .mode = .read_write }) catch {
std.fs.cwd().access(filename_slice, .{ .mode = .read_only }) catch {
accessed = false;
};
}
Expand Down
2 changes: 2 additions & 0 deletions tests/025-fs.buzz
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ test "ls" {
foreach (el in fs\list("/doesnotexist") catch ["wentwrong"]) {
std\assert(el == "wentwrong", message: "Trying to list a non existent directory raised an error");
}

std\assert(fs\exists("README.md"), message: "fs\\exists");
}

test "move" {
Expand Down

0 comments on commit 3cbc42a

Please sign in to comment.