diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-10-28 11:04:59 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-10-29 06:20:52 -0700 |
| commit | 6c794ce7bceeefceeee43a5514e633162ee946a9 (patch) | |
| tree | b8ee83006257c812be04f8ac658e0c525c7c52e0 /lib/std | |
| parent | 9f986419bd0409c0b6b7630f0c7222b4137ead4f (diff) | |
| download | zig-6c794ce7bceeefceeee43a5514e633162ee946a9.tar.gz zig-6c794ce7bceeefceeee43a5514e633162ee946a9.zip | |
std.Io.Threaded.dirOpenFileWtf16: SHARING_VIOLATION
is the error code that needs the kernel bug workaround, not
ACCESS_DENIED.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Io/File.zig | 6 | ||||
| -rw-r--r-- | lib/std/Io/Threaded.zig | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/Io/File.zig b/lib/std/Io/File.zig index ada57344e4..cc4ce64a22 100644 --- a/lib/std/Io/File.zig +++ b/lib/std/Io/File.zig @@ -221,13 +221,13 @@ pub fn readPositional(file: File, io: Io, buffer: []u8, offset: u64) ReadPositio pub const WriteStreamingError = error{} || Io.UnexpectedError || Io.Cancelable; -pub fn write(file: File, io: Io, buffer: []const u8) WriteStreamingError!usize { - return @errorCast(file.pwrite(io, buffer, -1)); +pub fn writeStreaming(file: File, io: Io, buffer: [][]const u8) WriteStreamingError!usize { + return file.fileWriteStreaming(io, buffer); } pub const WritePositionalError = WriteStreamingError || error{Unseekable}; -pub fn writePositional(file: File, io: Io, buffer: []const u8, offset: u64) WritePositionalError!usize { +pub fn writePositional(file: File, io: Io, buffer: [][]const u8, offset: u64) WritePositionalError!usize { return io.vtable.fileWritePositional(io.userdata, file, buffer, offset); } diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 83eea97990..345775b9eb 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -2120,18 +2120,18 @@ pub fn dirOpenFileWtf16( .BAD_NETWORK_NAME => return error.NetworkNotFound, // \\server was found but \\server\share wasn't .NO_MEDIA_IN_DEVICE => return error.NoDevice, .INVALID_PARAMETER => |err| return w.statusBug(err), - .SHARING_VIOLATION => return error.AccessDenied, - .ACCESS_DENIED => { + .SHARING_VIOLATION => { // This occurs if the file attempting to be opened is a running // executable. However, there's a kernel bug: the error may be // incorrectly returned for an indeterminate amount of time // after an executable file is closed. Here we work around the // kernel bug with retry attempts. - if (attempt - max_attempts == 0) return error.AccessDenied; + if (attempt - max_attempts == 0) return error.SharingViolation; _ = w.kernel32.SleepEx((@as(u32, 1) << attempt) >> 1, w.TRUE); attempt += 1; continue; }, + .ACCESS_DENIED => return error.AccessDenied, .PIPE_BUSY => return error.PipeBusy, .PIPE_NOT_AVAILABLE => return error.NoDevice, .OBJECT_PATH_SYNTAX_BAD => |err| return w.statusBug(err), @@ -2146,7 +2146,7 @@ pub fn dirOpenFileWtf16( // finished with the deletion operation, and so this CreateFile // call has failed. Here, we simulate the kernel bug being // fixed by sleeping and retrying until the error goes away. - if (attempt - max_attempts == 0) return error.AccessDenied; + if (attempt - max_attempts == 0) return error.SharingViolation; _ = w.kernel32.SleepEx((@as(u32, 1) << attempt) >> 1, w.TRUE); attempt += 1; continue; |
