diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-05-02 00:41:19 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-02 00:41:19 -0400 |
| commit | 2272a07ca0661547a6889aa7f1b6262fef5dad85 (patch) | |
| tree | c8e093b7c72ac3e1fc2e62931167294941becc7a /lib/std/os.zig | |
| parent | 45bce27b8fecda4fba1c22dd191030af29ccbc6f (diff) | |
| download | zig-2272a07ca0661547a6889aa7f1b6262fef5dad85.tar.gz zig-2272a07ca0661547a6889aa7f1b6262fef5dad85.zip | |
std.event.Loop: promote the fs thread to be available for all OS's
Diffstat (limited to 'lib/std/os.zig')
| -rw-r--r-- | lib/std/os.zig | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig index 05d8b60a2d..39f5d36ddf 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -854,8 +854,11 @@ pub const OpenError = error{ /// Open and possibly create a file. Keeps trying if it gets interrupted. /// See also `openC`. -/// TODO support windows pub fn open(file_path: []const u8, flags: u32, perm: usize) OpenError!fd_t { + if (std.Target.current.os.tag == .windows) { + const file_path_w = try windows.sliceToPrefixedFileW(file_path); + return openW(&file_path_w, flags, perm); + } const file_path_c = try toPosixPath(file_path); return openZ(&file_path_c, flags, perm); } @@ -864,8 +867,11 @@ pub const openC = @compileError("deprecated: renamed to openZ"); /// Open and possibly create a file. Keeps trying if it gets interrupted. /// See also `open`. -/// TODO support windows pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: usize) OpenError!fd_t { + if (std.Target.current.os.tag == .windows) { + const file_path_w = try windows.cStrToPrefixedFileW(file_path); + return openW(&file_path_w, flags, perm); + } while (true) { const rc = system.open(file_path, flags, perm); switch (errno(rc)) { @@ -895,6 +901,13 @@ pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: usize) OpenError!fd_t { } } +/// Windows-only. The path parameter is +/// [WTF-16](https://simonsapin.github.io/wtf-8/#potentially-ill-formed-utf-16) encoded. +/// Translates the POSIX open API call to a Windows API call. +pub fn openW(file_path_w: []const u16, flags: u32, perm: usize) OpenError!fd_t { + @compileError("TODO implement openW for windows"); +} + /// Open and possibly create a file. Keeps trying if it gets interrupted. /// `file_path` is relative to the open directory handle `dir_fd`. /// See also `openatC`. @@ -1683,7 +1696,7 @@ pub fn renameatW( .dir = old_dir_fd, .access_mask = windows.SYNCHRONIZE | windows.GENERIC_WRITE | windows.DELETE, .creation = windows.FILE_OPEN, - .enable_async_io = false, + .io_mode = .blocking, }) catch |err| switch (err) { error.WouldBlock => unreachable, // Not possible without `.share_access_nonblocking = true`. else => |e| return e, |
