From 1820d08d25aea732c8f2afc6b78b26f2a307c7ea Mon Sep 17 00:00:00 2001 From: Georgijs <48869301+gvilums@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:12:44 -0700 Subject: [PATCH] fix create with github URL on windows (#10231) * correctly ignore error on windows to match posix behavior * replace zig accessat with bun.sys.existsAt * fix posix build --- src/cli/create_command.zig | 12 +++++++++--- src/sys.zig | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index 9eed58bf42..bd3fa3be3f 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -1611,7 +1611,9 @@ pub const CreateCommand = struct { const outdir_path = filesystem.absBuf(&parts, &home_dir_buf); home_dir_buf[outdir_path.len] = 0; const outdir_path_ = home_dir_buf[0..outdir_path.len :0]; - std.fs.accessAbsoluteZ(outdir_path_, .{}) catch break :outer; + if (!bun.sys.existsAt(bun.invalid_fd, outdir_path_)) { + break :outer; + } example_tag = Example.Tag.local_folder; break :brk outdir_path; } @@ -1622,7 +1624,9 @@ pub const CreateCommand = struct { const outdir_path = filesystem.absBuf(&parts, &home_dir_buf); home_dir_buf[outdir_path.len] = 0; const outdir_path_ = home_dir_buf[0..outdir_path.len :0]; - std.fs.accessAbsoluteZ(outdir_path_, .{}) catch break :outer; + if (!bun.sys.existsAt(bun.invalid_fd, outdir_path_)) { + break :outer; + } example_tag = Example.Tag.local_folder; break :brk outdir_path; } @@ -1633,7 +1637,9 @@ pub const CreateCommand = struct { const outdir_path = filesystem.absBuf(&parts, &home_dir_buf); home_dir_buf[outdir_path.len] = 0; const outdir_path_ = home_dir_buf[0..outdir_path.len :0]; - std.fs.accessAbsoluteZ(outdir_path_, .{}) catch break :outer; + if (!bun.sys.existsAt(bun.invalid_fd, outdir_path_)) { + break :outer; + } example_tag = Example.Tag.local_folder; break :brk outdir_path; } diff --git a/src/sys.zig b/src/sys.zig index 33c3485755..ba7c690f72 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -2120,7 +2120,7 @@ pub fn exists(path: []const u8) bool { pub fn existsAt(fd: bun.FileDescriptor, subpath: []const u8) bool { if (comptime Environment.isPosix) { - return system.faccessat(bun.toFD(fd), &(std.os.toPosixPath(subpath) catch return false), 0, 0) == 0; + return system.faccessat(fd.cast(), &(std.os.toPosixPath(subpath) catch return false), 0, 0) == 0; } if (comptime Environment.isWindows) {