| ... | ... | @@ -238,7 +238,7 @@ pub fn close(fd: fd_t) void { |
| 238 | 238 | if (builtin.os.tag == .windows) { |
| 239 | 239 | return windows.CloseHandle(fd); |
| 240 | 240 | } |
| 241 | | if (builtin.os.tag == .wasi) { |
| 241 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 242 | 242 | _ = wasi.fd_close(fd); |
| 243 | 243 | return; |
| 244 | 244 | } |
| ... | ... | @@ -1395,7 +1395,7 @@ pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t |
| 1395 | 1395 | /// `file_path` is relative to the open directory handle `dir_fd`. |
| 1396 | 1396 | /// See also `openatZ`. |
| 1397 | 1397 | pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: u32, mode: mode_t) OpenError!fd_t { |
| 1398 | | if (builtin.os.tag == .wasi) { |
| 1398 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 1399 | 1399 | @compileError("use openatWasi instead"); |
| 1400 | 1400 | } |
| 1401 | 1401 | if (builtin.os.tag == .windows) { |
| ... | ... | @@ -1760,7 +1760,7 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { |
| 1760 | 1760 | if (builtin.os.tag == .windows) { |
| 1761 | 1761 | return windows.GetCurrentDirectory(out_buffer); |
| 1762 | 1762 | } |
| 1763 | | if (builtin.os.tag == .wasi) { |
| 1763 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 1764 | 1764 | @compileError("WASI doesn't have a concept of cwd(); use std.fs.wasi.PreopenList to get available Dir handles instead"); |
| 1765 | 1765 | } |
| 1766 | 1766 | |
| ... | ... | @@ -1804,7 +1804,7 @@ pub const SymLinkError = error{ |
| 1804 | 1804 | /// If `sym_link_path` exists, it will not be overwritten. |
| 1805 | 1805 | /// See also `symlinkZ. |
| 1806 | 1806 | pub fn symlink(target_path: []const u8, sym_link_path: []const u8) SymLinkError!void { |
| 1807 | | if (builtin.os.tag == .wasi) { |
| 1807 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 1808 | 1808 | @compileError("symlink is not supported in WASI; use symlinkat instead"); |
| 1809 | 1809 | } |
| 1810 | 1810 | if (builtin.os.tag == .windows) { |
| ... | ... | @@ -2021,7 +2021,7 @@ pub const UnlinkError = error{ |
| 2021 | 2021 | /// Delete a name and possibly the file it refers to. |
| 2022 | 2022 | /// See also `unlinkZ`. |
| 2023 | 2023 | pub fn unlink(file_path: []const u8) UnlinkError!void { |
| 2024 | | if (builtin.os.tag == .wasi) { |
| 2024 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 2025 | 2025 | @compileError("unlink is not supported in WASI; use unlinkat instead"); |
| 2026 | 2026 | } else if (builtin.os.tag == .windows) { |
| 2027 | 2027 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| ... | ... | @@ -2175,7 +2175,7 @@ pub const RenameError = error{ |
| 2175 | 2175 | |
| 2176 | 2176 | /// Change the name or location of a file. |
| 2177 | 2177 | pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { |
| 2178 | | if (builtin.os.tag == .wasi) { |
| 2178 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 2179 | 2179 | @compileError("rename is not supported in WASI; use renameat instead"); |
| 2180 | 2180 | } else if (builtin.os.tag == .windows) { |
| 2181 | 2181 | const old_path_w = try windows.sliceToPrefixedFileW(old_path); |
| ... | ... | @@ -2469,7 +2469,7 @@ pub const MakeDirError = error{ |
| 2469 | 2469 | /// Create a directory. |
| 2470 | 2470 | /// `mode` is ignored on Windows. |
| 2471 | 2471 | pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void { |
| 2472 | | if (builtin.os.tag == .wasi) { |
| 2472 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 2473 | 2473 | @compileError("mkdir is not supported in WASI; use mkdirat instead"); |
| 2474 | 2474 | } else if (builtin.os.tag == .windows) { |
| 2475 | 2475 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| ... | ... | @@ -2539,7 +2539,7 @@ pub const DeleteDirError = error{ |
| 2539 | 2539 | |
| 2540 | 2540 | /// Deletes an empty directory. |
| 2541 | 2541 | pub fn rmdir(dir_path: []const u8) DeleteDirError!void { |
| 2542 | | if (builtin.os.tag == .wasi) { |
| 2542 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 2543 | 2543 | @compileError("rmdir is not supported in WASI; use unlinkat instead"); |
| 2544 | 2544 | } else if (builtin.os.tag == .windows) { |
| 2545 | 2545 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| ... | ... | @@ -2600,7 +2600,7 @@ pub const ChangeCurDirError = error{ |
| 2600 | 2600 | /// Changes the current working directory of the calling process. |
| 2601 | 2601 | /// `dir_path` is recommended to be a UTF-8 encoded string. |
| 2602 | 2602 | pub fn chdir(dir_path: []const u8) ChangeCurDirError!void { |
| 2603 | | if (builtin.os.tag == .wasi) { |
| 2603 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 2604 | 2604 | @compileError("chdir is not supported in WASI"); |
| 2605 | 2605 | } else if (builtin.os.tag == .windows) { |
| 2606 | 2606 | var utf16_dir_path: [windows.PATH_MAX_WIDE]u16 = undefined; |
| ... | ... | @@ -2684,7 +2684,7 @@ pub const ReadLinkError = error{ |
| 2684 | 2684 | /// Read value of a symbolic link. |
| 2685 | 2685 | /// The return value is a slice of `out_buffer` from index 0. |
| 2686 | 2686 | pub fn readlink(file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 2687 | | if (builtin.os.tag == .wasi) { |
| 2687 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 2688 | 2688 | @compileError("readlink is not supported in WASI; use readlinkat instead"); |
| 2689 | 2689 | } else if (builtin.os.tag == .windows) { |
| 2690 | 2690 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| ... | ... | @@ -4631,7 +4631,7 @@ pub fn realpath(pathname: []const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealPathE |
| 4631 | 4631 | const pathname_w = try windows.sliceToPrefixedFileW(pathname); |
| 4632 | 4632 | return realpathW(pathname_w.span(), out_buffer); |
| 4633 | 4633 | } |
| 4634 | | if (builtin.os.tag == .wasi) { |
| 4634 | if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 4635 | 4635 | @compileError("Use std.fs.wasi.PreopenList to obtain valid Dir handles instead of using absolute paths"); |
| 4636 | 4636 | } |
| 4637 | 4637 | const pathname_c = try toPosixPath(pathname); |