diff options
author | 2022-10-10 20:59:34 -0700 | |
---|---|---|
committer | 2022-10-10 20:59:34 -0700 | |
commit | a114af4eea794e8b6a76b7cadc8f18730a52e8ad (patch) | |
tree | 0cd8bd74f3bc83d687fd710c20ed6d448be9e0e2 /src | |
parent | 5152aebde191e2543879a3029bfc8b67e8f4483f (diff) | |
download | bun-a114af4eea794e8b6a76b7cadc8f18730a52e8ad.tar.gz bun-a114af4eea794e8b6a76b7cadc8f18730a52e8ad.tar.zst bun-a114af4eea794e8b6a76b7cadc8f18730a52e8ad.zip |
Use write() and read() since not every file type supports positional
Diffstat (limited to 'src')
-rw-r--r-- | src/io/io_darwin.zig | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig index f40ba60c7..a551f935b 100644 --- a/src/io/io_darwin.zig +++ b/src/io/io_darwin.zig @@ -259,6 +259,7 @@ const fd_t = os.fd_t; const mem = std.mem; const assert = std.debug.assert; const c = std.c; +const bun = @import("../global.zig"); pub const darwin = struct { pub usingnamespace os.darwin; pub extern "c" fn @"recvfrom$NOCANCEL"(sockfd: c.fd_t, noalias buf: *anyopaque, len: usize, flags: u32, noalias src_addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) isize; @@ -1338,12 +1339,7 @@ pub fn read( struct { fn doOperation(op: anytype) ReadError!usize { while (true) { - const rc = if (op.positional) os.system.pread( - op.fd, - op.buf, - op.len, - @bitCast(isize, op.offset), - ) else os.system.read( + const rc = os.system.read( op.fd, op.buf, op.len, @@ -1576,7 +1572,10 @@ pub fn write( }, struct { fn doOperation(op: anytype) WriteError!usize { - return os.pwrite(op.fd, op.buf[0..op.len], op.offset); + + // Unlike Linux, macOS doesn't ignore file offsets for unseekable files, so we have to + // use write() instead of pwrite(). + return std.os.write(op.fd, op.buf[0..op.len]); } }, ); |