Commit 8d11ade6a7
lib/std/fs.zig
@@ -231,17 +231,17 @@ pub fn renameW(old_dir: Dir, old_sub_path_w: []const u16, new_dir: Dir, new_sub_
/// On POSIX targets, this function is comptime-callable.
pub fn cwd() Dir {
if (builtin.os.tag == .windows) {
- return Dir{ .fd = os.windows.peb().ProcessParameters.CurrentDirectory.Handle };
+ return .{ .fd = os.windows.peb().ProcessParameters.CurrentDirectory.Handle };
} else if (builtin.os.tag == .wasi) {
- return std.options.wasiCwd();
+ return .{ .fd = std.options.wasiCwd() };
} else {
- return Dir{ .fd = os.AT.FDCWD };
+ return .{ .fd = os.AT.FDCWD };
}
}
-pub fn defaultWasiCwd() Dir {
+pub fn defaultWasiCwd() std.os.wasi.fd_t {
// Expect the first preopen to be current working directory.
- return .{ .fd = 3 };
+ return 3;
}
/// Opens a directory at the given path. The directory is a system resource that remains
lib/std/std.zig
@@ -203,7 +203,7 @@ pub const Options = struct {
enable_segfault_handler: bool = debug.default_enable_segfault_handler,
/// Function used to implement `std.fs.cwd` for WASI.
- wasiCwd: fn () fs.Dir = fs.defaultWasiCwd,
+ wasiCwd: fn () os.wasi.fd_t = fs.defaultWasiCwd,
/// The current log level.
log_level: log.Level = log.default_level,
src/main.zig
@@ -45,11 +45,11 @@ pub const std_options = .{
pub const panic = crash_report.panic;
var wasi_preopens: fs.wasi.Preopens = undefined;
-pub fn wasi_cwd() fs.Dir {
+pub fn wasi_cwd() std.os.wasi.fd_t {
// Expect the first preopen to be current working directory.
const cwd_fd: std.os.fd_t = 3;
assert(mem.eql(u8, wasi_preopens.names[cwd_fd], "."));
- return .{ .fd = cwd_fd };
+ return cwd_fd;
}
pub fn getWasiPreopen(name: []const u8) Compilation.Directory {